egos-transfer 0.0.10 → 0.1.0
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 +8 -5
- package/package.json +1 -1
- package/src/index.ts +8 -5
package/dist/index.js
CHANGED
|
@@ -83,9 +83,7 @@ class PeerTransfer {
|
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
setTimeout(() => {
|
|
86
|
-
|
|
87
|
-
this.reconnect();
|
|
88
|
-
}
|
|
86
|
+
this.reconnect();
|
|
89
87
|
}, constant_1.CONNECTION_RETRY);
|
|
90
88
|
});
|
|
91
89
|
peer.on('error', (err) => {
|
|
@@ -119,6 +117,7 @@ class PeerTransfer {
|
|
|
119
117
|
socket.on('close', () => {
|
|
120
118
|
setTimeout(() => {
|
|
121
119
|
this.destroy();
|
|
120
|
+
this.reconnect();
|
|
122
121
|
}, constant_1.CONNECTION_RETRY);
|
|
123
122
|
});
|
|
124
123
|
this.onHeartbeat({ type: 'HEARTBEAT' });
|
|
@@ -156,7 +155,7 @@ class PeerTransfer {
|
|
|
156
155
|
return;
|
|
157
156
|
}
|
|
158
157
|
if (((_a = message.payload) === null || _a === void 0 ? void 0 : _a.msg) === constant_1.CONNECTION_PEER_CONFLICT) {
|
|
159
|
-
this.
|
|
158
|
+
this.stop();
|
|
160
159
|
this.getStore().dispatch({
|
|
161
160
|
type: 'global/updateNetworkState',
|
|
162
161
|
payload: {
|
|
@@ -474,8 +473,12 @@ class PeerTransfer {
|
|
|
474
473
|
}
|
|
475
474
|
reconnect() {
|
|
476
475
|
return __awaiter(this, void 0, void 0, function* () {
|
|
476
|
+
if (this.isPaused) {
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
console.log('peer reconnecting...');
|
|
477
480
|
if (this.reconnectingPromise) {
|
|
478
|
-
return this.reconnectingPromise;
|
|
481
|
+
return yield this.reconnectingPromise;
|
|
479
482
|
}
|
|
480
483
|
this.reconnectingPromise = this.doReconnect();
|
|
481
484
|
return this.reconnectingPromise.finally(() => {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -119,9 +119,7 @@ export abstract class PeerTransfer {
|
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
121
|
setTimeout(() => {
|
|
122
|
-
|
|
123
|
-
this.reconnect();
|
|
124
|
-
}
|
|
122
|
+
this.reconnect();
|
|
125
123
|
}, CONNECTION_RETRY);
|
|
126
124
|
});
|
|
127
125
|
peer.on('error', (err) => {
|
|
@@ -155,6 +153,7 @@ export abstract class PeerTransfer {
|
|
|
155
153
|
socket.on('close', () => {
|
|
156
154
|
setTimeout(() => {
|
|
157
155
|
this.destroy();
|
|
156
|
+
this.reconnect();
|
|
158
157
|
}, CONNECTION_RETRY);
|
|
159
158
|
});
|
|
160
159
|
this.onHeartbeat({ type: 'HEARTBEAT' } as IMessage);
|
|
@@ -193,7 +192,7 @@ export abstract class PeerTransfer {
|
|
|
193
192
|
return;
|
|
194
193
|
}
|
|
195
194
|
if (message.payload?.msg === CONNECTION_PEER_CONFLICT) {
|
|
196
|
-
this.
|
|
195
|
+
this.stop();
|
|
197
196
|
this.getStore().dispatch({
|
|
198
197
|
type: 'global/updateNetworkState',
|
|
199
198
|
payload: {
|
|
@@ -539,8 +538,12 @@ export abstract class PeerTransfer {
|
|
|
539
538
|
}
|
|
540
539
|
|
|
541
540
|
async reconnect(): Promise<Peer | undefined> {
|
|
541
|
+
if (this.isPaused) {
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
console.log('peer reconnecting...');
|
|
542
545
|
if (this.reconnectingPromise) {
|
|
543
|
-
return this.reconnectingPromise;
|
|
546
|
+
return await this.reconnectingPromise;
|
|
544
547
|
}
|
|
545
548
|
|
|
546
549
|
this.reconnectingPromise = this.doReconnect();
|