@ray-js/robot-data-stream 0.0.12-beta-10 → 0.0.12-beta-12

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.js CHANGED
@@ -26,11 +26,16 @@ export default class P2pApi {
26
26
  * 并清除定时器
27
27
  */
28
28
  // this.isConnected = false;
29
- if (this.isConnected || this.isConnecting) {
29
+ if (this.isConnected) {
30
30
  return logger('info', {
31
31
  msg: 'p2p isConnected or isConnecting'
32
32
  }, this.onLogger);
33
33
  }
34
+ if (this.isConnecting) {
35
+ return logger('info', {
36
+ msg: 'p2p isConnecting'
37
+ }, this.onLogger);
38
+ }
34
39
  // if (!this.isConnected) {
35
40
  logger('info', {
36
41
  msg: `${source} start p2p reconnect ==> ${moment().format('YYYY-MM-DD HH:mm:ss')}`
@@ -117,6 +122,7 @@ export default class P2pApi {
117
122
  logger('warn', {
118
123
  msg: `p2p connectDevice failed ==> ${JSON.stringify(params.innerError)}`
119
124
  }, this.onLogger);
125
+ this.isConnecting = false;
120
126
  typeof failCb === 'function' && failCb();
121
127
  resolve(false);
122
128
  },
@@ -126,6 +132,8 @@ export default class P2pApi {
126
132
  }
127
133
  });
128
134
  } catch (e) {
135
+ this.isConnecting = false;
136
+ this.isConnected = false;
129
137
  logger('error', {
130
138
  msg: 'p2p connectDevice occur an error ==>',
131
139
  e
@@ -216,7 +216,7 @@ export class SweeperP2p extends P2pApi {
216
216
  this.reconnectP2p(() => {
217
217
  // 重连之后重新开启文件下载, 这里的成功不需要注册断开事件
218
218
  this.startObserverSweeperDataByP2P(this.downloadType, this.devId, this.onReceiveMapData, this.onReceivePathData, this.onReceiveAIPicData, this.onReceiveAIPicHDData);
219
- }, '1111');
219
+ }, '');
220
220
  } else {
221
221
  logger('warn', {
222
222
  msg: 'receive disconnect notice, but connectDevice is connecting'
package/lib/index.js CHANGED
@@ -51,9 +51,9 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
51
51
  deviceId: devId
52
52
  })}`
53
53
  }, onLogger);
54
- if (!isInit.current || !((_ty$p2p$isP2PActiveSy2 = (_ty$p2p2 = ty.p2p).isP2PActiveSync) !== null && _ty$p2p$isP2PActiveSy2 !== void 0 && _ty$p2p$isP2PActiveSy2.call(_ty$p2p2, {
54
+ if ((!isInit.current || !((_ty$p2p$isP2PActiveSy2 = (_ty$p2p2 = ty.p2p).isP2PActiveSync) !== null && _ty$p2p$isP2PActiveSy2 !== void 0 && _ty$p2p$isP2PActiveSy2.call(_ty$p2p2, {
55
55
  deviceId: devId
56
- }))) {
56
+ }))) && !SweeperP2pInstance.isConnecting) {
57
57
  connectP2p();
58
58
  }
59
59
  }, 500);
@@ -111,7 +111,6 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
111
111
  logger('info', {
112
112
  msg: 'hooks has been started connectP2p'
113
113
  }, onLogger);
114
- SweeperP2pInstance.isConnecting = true;
115
114
  SweeperP2pInstance.connectDevice(() => {
116
115
  trace.pointFn('p2p', {
117
116
  devId,
@@ -134,7 +133,7 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
134
133
  SweeperP2pInstance.startObserverSweeperDataByP2P(1, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData);
135
134
  // 这里失败重连需要注册断开重连的事件
136
135
  offSessionStatusChange.current = SweeperP2pInstance.onSessionStatusChange(SweeperP2pInstance.sessionStatusCallback);
137
- }, '22222');
136
+ }, '');
138
137
  });
139
138
  };
140
139
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/robot-data-stream",
3
- "version": "0.0.12-beta-10",
3
+ "version": "0.0.12-beta-12",
4
4
  "description": "扫地机P2P数据流标准化组件",
5
5
  "main": "lib/index",
6
6
  "files": [