@ray-js/robot-data-stream 0.0.5-beta-1 → 0.0.5-beta-2
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/sweeperP2p.d.ts +2 -2
- package/lib/api/sweeperP2p.js +7 -3
- package/lib/index.js +11 -0
- package/package.json +1 -1
package/lib/api/sweeperP2p.d.ts
CHANGED
|
@@ -128,11 +128,11 @@ export declare class SweeperP2p extends P2pApi {
|
|
|
128
128
|
/**
|
|
129
129
|
* 注册下载有关的监听
|
|
130
130
|
*/
|
|
131
|
-
|
|
131
|
+
registerP2pDownloadEvent: () => void;
|
|
132
132
|
/**
|
|
133
133
|
* 移除下载有关的监听
|
|
134
134
|
*/
|
|
135
|
-
|
|
135
|
+
removeP2pDownloadEvent: () => void;
|
|
136
136
|
/**
|
|
137
137
|
* 单文件下载完成回调
|
|
138
138
|
* @param downloadComplete
|
package/lib/api/sweeperP2p.js
CHANGED
|
@@ -183,7 +183,7 @@ export class SweeperP2p extends P2pApi {
|
|
|
183
183
|
if (!this.isConnecting) {
|
|
184
184
|
this.reconnectP2p(() => {
|
|
185
185
|
// 重连之后重新开启文件下载, 这里的成功不需要注册断开事件
|
|
186
|
-
this.startObserverSweeperDataByP2P(this.downloadType, this.devId, this.onReceiveMapData, this.onReceivePathData);
|
|
186
|
+
this.startObserverSweeperDataByP2P(this.downloadType, this.devId, this.onReceiveMapData, this.onReceivePathData, this.onReceiveAIPicData, this.onReceiveAIPicHDData);
|
|
187
187
|
});
|
|
188
188
|
} else {
|
|
189
189
|
log4js.warn('receive disconnect notice, but connectDevice is connecting');
|
|
@@ -205,8 +205,12 @@ export class SweeperP2p extends P2pApi {
|
|
|
205
205
|
}
|
|
206
206
|
this.onReceiveMapData = onReceiveMapData;
|
|
207
207
|
this.onReceivePathData = onReceivePathData;
|
|
208
|
-
this.onReceiveAIPicData = onReceiveAIPicData || (() => {
|
|
209
|
-
|
|
208
|
+
this.onReceiveAIPicData = onReceiveAIPicData || (() => {
|
|
209
|
+
// do nothing
|
|
210
|
+
});
|
|
211
|
+
this.onReceiveAIPicHDData = onReceiveAIPicHDData || (() => {
|
|
212
|
+
// do nothing
|
|
213
|
+
});
|
|
210
214
|
log4js.info('startObserverSweeperDataByP2P ==>');
|
|
211
215
|
this.downloadType = downloadType;
|
|
212
216
|
this.setDataFilePath(devId);
|
package/lib/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import mitt from 'mitt';
|
|
|
4
4
|
import log4js from '@ray-js/log4js';
|
|
5
5
|
import { SweeperP2pInstance } from './api';
|
|
6
6
|
import sweeperP2pInstance from './api/sweeperP2p';
|
|
7
|
+
import { getSystemInfoSync } from '@ray-js/ray';
|
|
7
8
|
const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
|
|
8
9
|
const {
|
|
9
10
|
logTag,
|
|
@@ -14,6 +15,7 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
|
|
|
14
15
|
const offSessionStatusChange = useRef(null);
|
|
15
16
|
const isAppOnBackground = useRef(false);
|
|
16
17
|
const timer = useRef(null);
|
|
18
|
+
const isIDE = getSystemInfoSync().brand === 'devtools';
|
|
17
19
|
useEffect(() => {
|
|
18
20
|
if (logTag) {
|
|
19
21
|
log4js.setTag(logTag);
|
|
@@ -22,6 +24,15 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
|
|
|
22
24
|
log4js.warn('virtual device cannot use p2p');
|
|
23
25
|
return;
|
|
24
26
|
}
|
|
27
|
+
if (isIDE) {
|
|
28
|
+
log4js.warn(`You are using the IDE environment. To perform P2P and map debugging, please ensure the 'Robot Vacuum Debugger' plugin is installed.`);
|
|
29
|
+
SweeperP2pInstance.onReceiveMapData = onReceiveMapData;
|
|
30
|
+
SweeperP2pInstance.onReceivePathData = onReceivePathData;
|
|
31
|
+
SweeperP2pInstance.registerP2pDownloadEvent();
|
|
32
|
+
return () => {
|
|
33
|
+
SweeperP2pInstance.removeP2pDownloadEvent();
|
|
34
|
+
};
|
|
35
|
+
}
|
|
25
36
|
isInitP2p();
|
|
26
37
|
onEnterBackground();
|
|
27
38
|
onEnterForeground();
|