@ray-js/robot-data-stream 0.0.10-beta-22 → 0.0.10-beta-24
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 -1
- package/lib/api/sweeperP2p.js +10 -5
- package/lib/index.js +3 -4
- package/lib/utils/index.js +3 -6
- package/package.json +1 -1
package/lib/api/sweeperP2p.d.ts
CHANGED
|
@@ -181,7 +181,7 @@ export declare class SweeperP2p extends P2pApi {
|
|
|
181
181
|
/**
|
|
182
182
|
* 停止文件下载
|
|
183
183
|
*/
|
|
184
|
-
stopObserverSweeperDataByP2P: () =>
|
|
184
|
+
stopObserverSweeperDataByP2P: () => false | undefined;
|
|
185
185
|
}
|
|
186
186
|
declare const sweeperP2pInstance: SweeperP2p;
|
|
187
187
|
export default sweeperP2pInstance;
|
package/lib/api/sweeperP2p.js
CHANGED
|
@@ -630,8 +630,17 @@ export class SweeperP2p extends P2pApi {
|
|
|
630
630
|
* 停止文件下载
|
|
631
631
|
*/
|
|
632
632
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, consistent-return
|
|
633
|
-
stopObserverSweeperDataByP2P =
|
|
633
|
+
stopObserverSweeperDataByP2P = () => {
|
|
634
634
|
try {
|
|
635
|
+
logger('info', {
|
|
636
|
+
msg: `isConnected: ${this.isConnected}, devId: ${this.devId}`
|
|
637
|
+
}, this.onLogger);
|
|
638
|
+
if (this.isConnected) {
|
|
639
|
+
logger('info', {
|
|
640
|
+
msg: `try disconnect device, devId: ${this.devId}`
|
|
641
|
+
}, this.onLogger);
|
|
642
|
+
this.disconnectDevice();
|
|
643
|
+
}
|
|
635
644
|
this.removeP2pDownloadEvent();
|
|
636
645
|
// 没有必要cancelDownloadTask,只需要调用断连
|
|
637
646
|
// this.cancelDownloadTask();
|
|
@@ -639,10 +648,6 @@ export class SweeperP2p extends P2pApi {
|
|
|
639
648
|
// 先销毁断开监听
|
|
640
649
|
typeof this.offSessionStatusChange === 'function' && this.offSessionStatusChange();
|
|
641
650
|
// 销毁初始化时,先进行断连操作
|
|
642
|
-
|
|
643
|
-
if (this.isConnected) {
|
|
644
|
-
this.disconnectDevice();
|
|
645
|
-
}
|
|
646
651
|
} catch (e) {
|
|
647
652
|
logger('error', {
|
|
648
653
|
msg: 'stopObserverSweeperDataByP2P occur error ==>',
|
package/lib/index.js
CHANGED
|
@@ -96,10 +96,9 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
|
|
|
96
96
|
}, []);
|
|
97
97
|
usePageEvent('onUnload', () => {
|
|
98
98
|
unmount();
|
|
99
|
-
SweeperP2pInstance.deInitP2PSDK();
|
|
100
99
|
ty.offAppHide(handleAppHide);
|
|
101
100
|
ty.offAppShow(handleAppShow);
|
|
102
|
-
|
|
101
|
+
SweeperP2pInstance.deInitP2PSDK();
|
|
103
102
|
});
|
|
104
103
|
|
|
105
104
|
/**
|
|
@@ -139,16 +138,16 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
|
|
|
139
138
|
/**
|
|
140
139
|
* p2p断开
|
|
141
140
|
*/
|
|
142
|
-
const unmount =
|
|
141
|
+
const unmount = () => {
|
|
143
142
|
logger('info', {
|
|
144
143
|
msg: 'hooks has been started unmount'
|
|
145
144
|
}, onLogger);
|
|
146
145
|
isInit.current = false;
|
|
146
|
+
SweeperP2pInstance.stopObserverSweeperDataByP2P();
|
|
147
147
|
if (offSessionStatusChange.current) {
|
|
148
148
|
offSessionStatusChange.current();
|
|
149
149
|
offSessionStatusChange.current = null;
|
|
150
150
|
}
|
|
151
|
-
SweeperP2pInstance.stopObserverSweeperDataByP2P();
|
|
152
151
|
};
|
|
153
152
|
return {
|
|
154
153
|
appendDownloadStreamDuringTask: SweeperP2pInstance.appendDownloadStreamDuringTask
|
package/lib/utils/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
-
const _excluded = ["msg"];
|
|
3
1
|
import mitt from 'mitt';
|
|
4
2
|
import { floor, join, map } from 'lodash-es';
|
|
5
3
|
import log4js from '@ray-js/log4js';
|
|
@@ -50,10 +48,9 @@ export const parseJSON = str => {
|
|
|
50
48
|
};
|
|
51
49
|
export const logger = (type, params, onLogger) => {
|
|
52
50
|
const {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
log4js[type](msg, others);
|
|
51
|
+
msg
|
|
52
|
+
} = params;
|
|
53
|
+
log4js[type](msg);
|
|
57
54
|
if (onLogger) {
|
|
58
55
|
onLogger(type, msg);
|
|
59
56
|
}
|