egos-transfer 0.0.9 → 0.0.10

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/dist/index.d.ts CHANGED
@@ -53,7 +53,7 @@ export declare abstract class PeerTransfer {
53
53
  getDeviceStatus(peerId: string): Promise<IDeviceStatus | undefined>;
54
54
  connectToPeer(deviceId: string): Promise<DataConnection | undefined>;
55
55
  ping(peerId: string): Promise<boolean>;
56
- onConnect(conn: DataConnection, positive?: boolean): Promise<DataConnection | undefined>;
56
+ onConnect(conn: DataConnection): Promise<DataConnection | undefined>;
57
57
  request(peerId: string, payload: PeerRequestPayload): Promise<PeerMessage>;
58
58
  reply(conn: DataConnection, oldMessage: PeerMessage, message: {
59
59
  body?: Record<string, any>;
package/dist/index.js CHANGED
@@ -66,7 +66,7 @@ class PeerTransfer {
66
66
  });
67
67
  });
68
68
  peer.on('connection', (conn) => {
69
- this.onConnect(conn, false);
69
+ this.onConnect(conn);
70
70
  });
71
71
  peer.on('disconnected', () => {
72
72
  if (!this.isPaused) {
@@ -189,8 +189,8 @@ class PeerTransfer {
189
189
  return;
190
190
  }
191
191
  const deviceId = message.payload.deviceId;
192
- this.removeConnection(deviceId);
193
192
  this.offline(deviceId);
193
+ this.ping(deviceId);
194
194
  }
195
195
  removeConnection(peerId) {
196
196
  var _a, _b;
@@ -200,6 +200,7 @@ class PeerTransfer {
200
200
  clearInterval((_b = conn.metadata) === null || _b === void 0 ? void 0 : _b.intervalId);
201
201
  }
202
202
  this.connectPool.delete(peerId);
203
+ this.offline(peerId);
203
204
  }
204
205
  }
205
206
  addConnection(conn) {
@@ -327,6 +328,9 @@ class PeerTransfer {
327
328
  }
328
329
  ping(peerId) {
329
330
  return __awaiter(this, void 0, void 0, function* () {
331
+ if (this.deviceId === peerId) {
332
+ return;
333
+ }
330
334
  const conn = this.connectPool.get(peerId);
331
335
  if (!conn) {
332
336
  return;
@@ -344,8 +348,8 @@ class PeerTransfer {
344
348
  return true;
345
349
  });
346
350
  }
347
- onConnect(conn_1) {
348
- return __awaiter(this, arguments, void 0, function* (conn, positive = true) {
351
+ onConnect(conn) {
352
+ return __awaiter(this, void 0, void 0, function* () {
349
353
  if (!conn) {
350
354
  return;
351
355
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "egos-transfer",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "1234",
5
5
  "homepage": "https://github.com/superbogy/peer-transfer#readme",
6
6
  "bugs": {
package/src/index.ts CHANGED
@@ -102,7 +102,7 @@ export abstract class PeerTransfer {
102
102
  });
103
103
  });
104
104
  peer.on('connection', (conn) => {
105
- this.onConnect(conn, false);
105
+ this.onConnect(conn);
106
106
  });
107
107
  peer.on('disconnected', () => {
108
108
  if (!this.isPaused) {
@@ -227,8 +227,8 @@ export abstract class PeerTransfer {
227
227
  return;
228
228
  }
229
229
  const deviceId = message.payload.deviceId;
230
- this.removeConnection(deviceId);
231
230
  this.offline(deviceId);
231
+ this.ping(deviceId);
232
232
  }
233
233
 
234
234
  removeConnection(peerId: string) {
@@ -238,6 +238,7 @@ export abstract class PeerTransfer {
238
238
  clearInterval(conn.metadata?.intervalId);
239
239
  }
240
240
  this.connectPool.delete(peerId);
241
+ this.offline(peerId);
241
242
  }
242
243
  }
243
244
 
@@ -361,6 +362,9 @@ export abstract class PeerTransfer {
361
362
  }
362
363
 
363
364
  async ping(peerId: string) {
365
+ if (this.deviceId === peerId) {
366
+ return;
367
+ }
364
368
  const conn = this.connectPool.get(peerId);
365
369
  if (!conn) {
366
370
  return;
@@ -378,7 +382,7 @@ export abstract class PeerTransfer {
378
382
  return true;
379
383
  }
380
384
 
381
- async onConnect(conn: DataConnection, positive = true): Promise<DataConnection | undefined> {
385
+ async onConnect(conn: DataConnection): Promise<DataConnection | undefined> {
382
386
  if (!conn) {
383
387
  return;
384
388
  }