@ray-js/robot-data-stream 0.0.10-beta-23 → 0.0.10-beta-25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/p2pApi.d.ts +1 -3
- package/lib/api/p2pApi.js +1 -4
- package/lib/api/sweeperP2p.d.ts +1 -3
- package/lib/api/sweeperP2p.js +3 -3
- package/lib/index.js +3 -5
- package/package.json +1 -1
package/lib/api/p2pApi.d.ts
CHANGED
package/lib/api/p2pApi.js
CHANGED
|
@@ -11,12 +11,9 @@ import { trace } from '../trace';
|
|
|
11
11
|
export default class P2pApi {
|
|
12
12
|
// P2p连接状态
|
|
13
13
|
|
|
14
|
-
constructor(
|
|
14
|
+
constructor() {
|
|
15
15
|
this.isConnected = false;
|
|
16
16
|
this.isConnecting = false;
|
|
17
|
-
if (props && props.onLogger) {
|
|
18
|
-
this.onLogger = props === null || props === void 0 ? void 0 : props.onLogger;
|
|
19
|
-
}
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
/**
|
package/lib/api/sweeperP2p.d.ts
CHANGED
|
@@ -74,9 +74,7 @@ export declare class SweeperP2p extends P2pApi {
|
|
|
74
74
|
offTotalDownLoadProgressUpdate: () => void;
|
|
75
75
|
onDefineStructuredMode: (isStructured: boolean) => void;
|
|
76
76
|
mapUpdateCount: number;
|
|
77
|
-
constructor(props:
|
|
78
|
-
onLogger: (type: 'warn' | 'error' | 'info', data: string) => void;
|
|
79
|
-
});
|
|
77
|
+
constructor(props: any);
|
|
80
78
|
private setStreamFilePath;
|
|
81
79
|
private setDataFilePath;
|
|
82
80
|
/**
|
package/lib/api/sweeperP2p.js
CHANGED
|
@@ -51,9 +51,6 @@ const shouldDownloadStream = Boolean(ty.p2p.downloadStream && ty.p2p.onStreamPac
|
|
|
51
51
|
export class SweeperP2p extends P2pApi {
|
|
52
52
|
constructor(props) {
|
|
53
53
|
super(props);
|
|
54
|
-
if (props && props.onLogger) {
|
|
55
|
-
this.onLogger = props.onLogger;
|
|
56
|
-
}
|
|
57
54
|
this.file = undefined;
|
|
58
55
|
this.downloadType = 1;
|
|
59
56
|
this.fileIndex = -1; // -1 表示所有文件下载完成
|
|
@@ -632,6 +629,9 @@ export class SweeperP2p extends P2pApi {
|
|
|
632
629
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, consistent-return
|
|
633
630
|
stopObserverSweeperDataByP2P = () => {
|
|
634
631
|
try {
|
|
632
|
+
logger('info', {
|
|
633
|
+
msg: `isConnected: ${this.isConnected}, devId: ${this.devId}`
|
|
634
|
+
}, this.onLogger);
|
|
635
635
|
if (this.isConnected) {
|
|
636
636
|
logger('info', {
|
|
637
637
|
msg: `try disconnect device, devId: ${this.devId}`
|
package/lib/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import log4js from '@ray-js/log4js';
|
|
3
3
|
import { getSystemInfoSync, usePageEvent } from '@ray-js/ray';
|
|
4
4
|
import { useCallback, useEffect, useRef } from 'react';
|
|
5
|
-
import { SweeperP2p } from './api/sweeperP2p';
|
|
6
5
|
import { trace } from './trace';
|
|
7
6
|
import { emitter, logger } from './utils';
|
|
7
|
+
import { SweeperP2pInstance } from './api';
|
|
8
8
|
export * from './mqtt';
|
|
9
9
|
export * from './mqtt/type/requestType';
|
|
10
10
|
const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
|
|
@@ -20,9 +20,6 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
|
|
|
20
20
|
const isAppOnBackground = useRef(false);
|
|
21
21
|
const timer = useRef(null);
|
|
22
22
|
const isIDE = getSystemInfoSync().brand === 'devtools';
|
|
23
|
-
const SweeperP2pInstance = new SweeperP2p({
|
|
24
|
-
onLogger
|
|
25
|
-
});
|
|
26
23
|
const handleAppHide = useCallback(() => {
|
|
27
24
|
logger('info', {
|
|
28
25
|
msg: 'hooks onAppHide'
|
|
@@ -79,6 +76,7 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
|
|
|
79
76
|
}, onLogger);
|
|
80
77
|
return;
|
|
81
78
|
}
|
|
79
|
+
SweeperP2pInstance.onLogger = onLogger;
|
|
82
80
|
SweeperP2pInstance.initP2pSdk(devId).then(() => {
|
|
83
81
|
connectP2p();
|
|
84
82
|
trace.pointFn('p2p', {
|
|
@@ -143,11 +141,11 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
|
|
|
143
141
|
msg: 'hooks has been started unmount'
|
|
144
142
|
}, onLogger);
|
|
145
143
|
isInit.current = false;
|
|
144
|
+
SweeperP2pInstance.stopObserverSweeperDataByP2P();
|
|
146
145
|
if (offSessionStatusChange.current) {
|
|
147
146
|
offSessionStatusChange.current();
|
|
148
147
|
offSessionStatusChange.current = null;
|
|
149
148
|
}
|
|
150
|
-
SweeperP2pInstance.stopObserverSweeperDataByP2P();
|
|
151
149
|
};
|
|
152
150
|
return {
|
|
153
151
|
appendDownloadStreamDuringTask: SweeperP2pInstance.appendDownloadStreamDuringTask
|