@ray-js/robot-data-stream 0.0.10-beta-5 → 0.0.10-beta-6
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 +1 -2
- package/lib/api/sweeperP2p.js +2 -8
- package/lib/index.d.ts +0 -1
- package/lib/index.js +2 -3
- package/package.json +1 -1
package/lib/api/sweeperP2p.d.ts
CHANGED
|
@@ -52,7 +52,6 @@ export declare class SweeperP2p extends P2pApi {
|
|
|
52
52
|
streamFilePath: string;
|
|
53
53
|
dataFilePath: string;
|
|
54
54
|
downloadType: number;
|
|
55
|
-
useStructuredMode: boolean;
|
|
56
55
|
readingMap: boolean;
|
|
57
56
|
readingClean: boolean;
|
|
58
57
|
readingAI: boolean;
|
|
@@ -124,7 +123,7 @@ export declare class SweeperP2p extends P2pApi {
|
|
|
124
123
|
* @param downloadType
|
|
125
124
|
* 0: 下载断开 1: 持续下载
|
|
126
125
|
*/
|
|
127
|
-
startObserverSweeperDataByP2P: (downloadType: number,
|
|
126
|
+
startObserverSweeperDataByP2P: (downloadType: number, devId: string, onReceiveMapData: (data: string) => void, onReceivePathData: (data: string) => void, onReceiveAIPicData?: ((data: string) => void) | undefined, onReceiveAIPicHDData?: ((data: string) => void) | undefined) => Promise<void>;
|
|
128
127
|
/**
|
|
129
128
|
* 在下载过程中继续添加下载文件
|
|
130
129
|
* @param files
|
package/lib/api/sweeperP2p.js
CHANGED
|
@@ -50,7 +50,6 @@ export class SweeperP2p extends P2pApi {
|
|
|
50
50
|
super();
|
|
51
51
|
this.file = undefined;
|
|
52
52
|
this.downloadType = 1;
|
|
53
|
-
this.useStructuredMode = false;
|
|
54
53
|
this.fileIndex = -1; // -1 表示所有文件下载完成
|
|
55
54
|
this.albumName = 'ipc_sweeper_robot';
|
|
56
55
|
this.cacheDir = ty.env.USER_DATA_PATH;
|
|
@@ -195,7 +194,7 @@ export class SweeperP2p extends P2pApi {
|
|
|
195
194
|
if (!this.isConnecting) {
|
|
196
195
|
this.reconnectP2p(() => {
|
|
197
196
|
// 重连之后重新开启文件下载, 这里的成功不需要注册断开事件
|
|
198
|
-
this.startObserverSweeperDataByP2P(this.downloadType, this.
|
|
197
|
+
this.startObserverSweeperDataByP2P(this.downloadType, this.devId, this.onReceiveMapData, this.onReceivePathData, this.onReceiveAIPicData, this.onReceiveAIPicHDData);
|
|
199
198
|
});
|
|
200
199
|
} else {
|
|
201
200
|
log4js.warn('receive disconnect notice, but connectDevice is connecting');
|
|
@@ -209,7 +208,7 @@ export class SweeperP2p extends P2pApi {
|
|
|
209
208
|
* @param downloadType
|
|
210
209
|
* 0: 下载断开 1: 持续下载
|
|
211
210
|
*/
|
|
212
|
-
startObserverSweeperDataByP2P = async (downloadType,
|
|
211
|
+
startObserverSweeperDataByP2P = async (downloadType, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData) => {
|
|
213
212
|
var _this$file$items;
|
|
214
213
|
if (![0, 1].some(item => item === downloadType)) {
|
|
215
214
|
log4js.warn('download type must be 0 or 1');
|
|
@@ -224,7 +223,6 @@ export class SweeperP2p extends P2pApi {
|
|
|
224
223
|
// do nothing
|
|
225
224
|
});
|
|
226
225
|
log4js.info('startObserverSweeperDataByP2P ==>');
|
|
227
|
-
this.useStructuredMode = useStructuredMode;
|
|
228
226
|
this.downloadType = downloadType;
|
|
229
227
|
this.setDataFilePath(devId);
|
|
230
228
|
this.setStreamFilePath(devId);
|
|
@@ -559,10 +557,6 @@ export class SweeperP2p extends P2pApi {
|
|
|
559
557
|
}
|
|
560
558
|
}
|
|
561
559
|
});
|
|
562
|
-
// 如果是使用结构化的数据,则直接把map. 相关的文件过滤掉
|
|
563
|
-
if (this.useStructuredMode) {
|
|
564
|
-
return exitFiles.filter(item => item.indexOf('map.') === -1);
|
|
565
|
-
}
|
|
566
560
|
return exitFiles;
|
|
567
561
|
};
|
|
568
562
|
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
declare const useP2PDataStream: (devId: string, onReceiveMapData: (data: string) => void, onReceivePathData: (data: string) => void, opt?: {
|
|
2
2
|
logTag?: string | undefined;
|
|
3
|
-
useStructuredMode?: boolean | undefined;
|
|
4
3
|
onReceiveAIPicData?: ((data: string) => void) | undefined;
|
|
5
4
|
onReceiveAIPicHDData?: ((data: string) => void) | undefined;
|
|
6
5
|
} | undefined) => {
|
package/lib/index.js
CHANGED
|
@@ -8,7 +8,6 @@ import { getSystemInfoSync, usePageEvent } from '@ray-js/ray';
|
|
|
8
8
|
const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
|
|
9
9
|
const {
|
|
10
10
|
logTag,
|
|
11
|
-
useStructuredMode = false,
|
|
12
11
|
onReceiveAIPicData,
|
|
13
12
|
onReceiveAIPicHDData
|
|
14
13
|
} = opt || {};
|
|
@@ -54,12 +53,12 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
|
|
|
54
53
|
SweeperP2pInstance.isConnecting = true;
|
|
55
54
|
SweeperP2pInstance.connectDevice(() => {
|
|
56
55
|
isInit.current = true;
|
|
57
|
-
SweeperP2pInstance.startObserverSweeperDataByP2P(1,
|
|
56
|
+
SweeperP2pInstance.startObserverSweeperDataByP2P(1, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData);
|
|
58
57
|
offSessionStatusChange.current = SweeperP2pInstance.onSessionStatusChange(SweeperP2pInstance.sessionStatusCallback);
|
|
59
58
|
}, () => {
|
|
60
59
|
SweeperP2pInstance.reconnectP2p(() => {
|
|
61
60
|
isInit.current = true;
|
|
62
|
-
SweeperP2pInstance.startObserverSweeperDataByP2P(1,
|
|
61
|
+
SweeperP2pInstance.startObserverSweeperDataByP2P(1, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData);
|
|
63
62
|
// 这里失败重连需要注册断开重连的事件
|
|
64
63
|
offSessionStatusChange.current = SweeperP2pInstance.onSessionStatusChange(SweeperP2pInstance.sessionStatusCallback);
|
|
65
64
|
});
|