@ray-js/robot-data-stream 0.0.12-beta-2 → 0.0.12-beta-3

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.
@@ -2,11 +2,11 @@ import "core-js/modules/esnext.iterator.constructor.js";
2
2
  import "core-js/modules/esnext.iterator.for-each.js";
3
3
  import "core-js/modules/esnext.iterator.map.js";
4
4
  /* eslint-disable no-shadow */
5
- import P2pApi from './p2pApi';
6
5
  import Base64 from 'base64-js';
7
- import { padStart, join, map, once } from 'lodash-es';
8
- import { logger } from '../utils';
6
+ import { join, map, padStart } from 'lodash-es';
9
7
  import { trace } from '../trace';
8
+ import { logger } from '../utils';
9
+ import P2pApi from './p2pApi';
10
10
  /**
11
11
  * 基于P2p工具类的扫地机扩展实现
12
12
  */
@@ -275,7 +275,23 @@ export class SweeperP2p extends P2pApi {
275
275
  // 开启p2p流传输
276
276
  await this.downloadStream({
277
277
  files: exitFiles
278
- }, this.albumName);
278
+ }, this.albumName, () => {
279
+ logger('info', {
280
+ msg: 'p2p downloadStream success===>'
281
+ }, this.onLogger);
282
+ }, () => {
283
+ logger('error', {
284
+ msg: 'p2p downloadStream failed and try reConnect Device===>'
285
+ }, this.onLogger);
286
+ this.removeP2pDownloadEvent();
287
+ this.disconnectDevice();
288
+ this.isConnected = false;
289
+ this.isConnecting = false;
290
+ this.reconnectP2p(() => {
291
+ // 重连之后重新开启文件下载, 这里的成功不需要注册断开事件
292
+ this.startObserverSweeperDataByP2P(this.downloadType, this.devId, this.onReceiveMapData, this.onReceivePathData, this.onReceiveAIPicData, this.onReceiveAIPicHDData);
293
+ });
294
+ });
279
295
  } else if (await this.initFilePath(this.dataFilePath)) {
280
296
  await this.downloadFile({
281
297
  files: exitFiles
@@ -22,7 +22,7 @@ export function normalResolve(reqType, taskId) {
22
22
  return new Promise((resolve, reject) => {
23
23
  // 设置超时定时器
24
24
  const timer = setTimeout(() => {
25
- reject(new MyError(`${taskId} Request timed out `, {
25
+ reject(new MyError(`${taskId} ${reqType} Request timed out `, {
26
26
  errCode: -1,
27
27
  reqType
28
28
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/robot-data-stream",
3
- "version": "0.0.12-beta-2",
3
+ "version": "0.0.12-beta-3",
4
4
  "description": "扫地机P2P数据流标准化组件",
5
5
  "main": "lib/index",
6
6
  "files": [