egos-transfer 0.1.7 → 0.1.8
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.js +14 -13
- package/package.json +1 -1
- package/src/index.ts +13 -13
package/dist/index.js
CHANGED
|
@@ -119,7 +119,7 @@ class PeerTransfer {
|
|
|
119
119
|
return this.reconnect();
|
|
120
120
|
}
|
|
121
121
|
done(null);
|
|
122
|
-
return this.
|
|
122
|
+
return this.createPeer(true);
|
|
123
123
|
}));
|
|
124
124
|
});
|
|
125
125
|
peer.on('connection', (conn) => {
|
|
@@ -227,7 +227,7 @@ class PeerTransfer {
|
|
|
227
227
|
}
|
|
228
228
|
checkConnection() {
|
|
229
229
|
if (this.checkerId) {
|
|
230
|
-
|
|
230
|
+
clearInterval(this.checkerId);
|
|
231
231
|
}
|
|
232
232
|
this.checkerId = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
233
233
|
var _a;
|
|
@@ -235,21 +235,22 @@ class PeerTransfer {
|
|
|
235
235
|
yield this.reconnect();
|
|
236
236
|
}
|
|
237
237
|
// turn credential expires
|
|
238
|
-
if (this.peerConfig.turnExpiredAt &&
|
|
238
|
+
if (this.peerConfig.turnExpiredAt && this.peerConfig.turnExpiredAt - 30000 < Date.now()) {
|
|
239
239
|
// this.connectPool.clear();
|
|
240
|
+
yield this.reloadConfig();
|
|
240
241
|
yield this.createPeer(true);
|
|
241
242
|
return;
|
|
242
243
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
244
|
+
const deviceIds = this.connectPool.keys();
|
|
245
|
+
for (const deviceId of deviceIds) {
|
|
246
|
+
const conn = this.connectPool.get(deviceId);
|
|
247
|
+
if (!this.isValidConnection(conn)) {
|
|
248
|
+
this.removeConnection(conn.peer);
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
this.ping(conn.peer);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
253
254
|
}), constant_1.HEARTBEAT_INTERVAL);
|
|
254
255
|
}
|
|
255
256
|
getApiHost() {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -161,7 +161,7 @@ export abstract class PeerTransfer {
|
|
|
161
161
|
return this.reconnect();
|
|
162
162
|
}
|
|
163
163
|
done(null);
|
|
164
|
-
return this.
|
|
164
|
+
return this.createPeer(true);
|
|
165
165
|
});
|
|
166
166
|
});
|
|
167
167
|
peer.on('connection', (conn: DataConnection) => {
|
|
@@ -272,28 +272,28 @@ export abstract class PeerTransfer {
|
|
|
272
272
|
|
|
273
273
|
checkConnection() {
|
|
274
274
|
if (this.checkerId) {
|
|
275
|
-
|
|
275
|
+
clearInterval(this.checkerId);
|
|
276
276
|
}
|
|
277
277
|
this.checkerId = setInterval(async () => {
|
|
278
278
|
if (!this.peer?.open) {
|
|
279
279
|
await this.reconnect();
|
|
280
280
|
}
|
|
281
281
|
// turn credential expires
|
|
282
|
-
if (this.peerConfig.turnExpiredAt &&
|
|
282
|
+
if (this.peerConfig.turnExpiredAt && this.peerConfig.turnExpiredAt - 30000 < Date.now()) {
|
|
283
283
|
// this.connectPool.clear();
|
|
284
|
+
await this.reloadConfig();
|
|
284
285
|
await this.createPeer(true);
|
|
285
286
|
return;
|
|
286
287
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
// }
|
|
288
|
+
const deviceIds = this.connectPool.keys();
|
|
289
|
+
for (const deviceId of deviceIds) {
|
|
290
|
+
const conn = this.connectPool.get(deviceId);
|
|
291
|
+
if (!this.isValidConnection(conn)) {
|
|
292
|
+
this.removeConnection(conn.peer);
|
|
293
|
+
} else {
|
|
294
|
+
this.ping(conn.peer);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
297
|
}, HEARTBEAT_INTERVAL);
|
|
298
298
|
}
|
|
299
299
|
|