@tentou-tech/poly-websockets 1.0.0 → 1.0.1
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.
|
@@ -376,7 +376,8 @@ class WSSubscriptionManager {
|
|
|
376
376
|
// (pendingUnsubscribeAssetIds is already cleared at this point)
|
|
377
377
|
if (this.subscribedAssetIds.size === 0 &&
|
|
378
378
|
this.pendingSubscribeAssetIds.size === 0 &&
|
|
379
|
-
this.pendingUnsubscribeAssetIds.size === 0
|
|
379
|
+
this.pendingUnsubscribeAssetIds.size === 0 &&
|
|
380
|
+
!this.enableCustomFeatures) {
|
|
380
381
|
this.closeWebSocket();
|
|
381
382
|
}
|
|
382
383
|
}
|
|
@@ -408,8 +409,9 @@ class WSSubscriptionManager {
|
|
|
408
409
|
async checkReconnection() {
|
|
409
410
|
// If we have pending assets but no connection, reconnect
|
|
410
411
|
const hasPendingAssets = this.pendingSubscribeAssetIds.size > 0;
|
|
412
|
+
const shouldReconnect = hasPendingAssets || this.enableCustomFeatures;
|
|
411
413
|
const isDisconnected = !this.wsClient || this.wsClient.readyState !== ws_1.default.OPEN;
|
|
412
|
-
if (
|
|
414
|
+
if (shouldReconnect && isDisconnected && !this.connecting) {
|
|
413
415
|
logger_1.logger.info({
|
|
414
416
|
message: 'Reconnection check - attempting to reconnect',
|
|
415
417
|
managerId: this.managerId,
|
|
@@ -432,7 +434,9 @@ class WSSubscriptionManager {
|
|
|
432
434
|
return;
|
|
433
435
|
}
|
|
434
436
|
// No assets to subscribe to
|
|
435
|
-
if (this.pendingSubscribeAssetIds.size === 0 &&
|
|
437
|
+
if (this.pendingSubscribeAssetIds.size === 0 &&
|
|
438
|
+
this.subscribedAssetIds.size === 0 &&
|
|
439
|
+
!this.enableCustomFeatures) {
|
|
436
440
|
return;
|
|
437
441
|
}
|
|
438
442
|
this.connecting = true;
|
package/package.json
CHANGED
|
@@ -452,7 +452,8 @@ class WSSubscriptionManager {
|
|
|
452
452
|
// (pendingUnsubscribeAssetIds is already cleared at this point)
|
|
453
453
|
if (this.subscribedAssetIds.size === 0 &&
|
|
454
454
|
this.pendingSubscribeAssetIds.size === 0 &&
|
|
455
|
-
this.pendingUnsubscribeAssetIds.size === 0
|
|
455
|
+
this.pendingUnsubscribeAssetIds.size === 0 &&
|
|
456
|
+
!this.enableCustomFeatures) {
|
|
456
457
|
this.closeWebSocket();
|
|
457
458
|
}
|
|
458
459
|
}
|
|
@@ -489,9 +490,10 @@ class WSSubscriptionManager {
|
|
|
489
490
|
private async checkReconnection() {
|
|
490
491
|
// If we have pending assets but no connection, reconnect
|
|
491
492
|
const hasPendingAssets = this.pendingSubscribeAssetIds.size > 0;
|
|
493
|
+
const shouldReconnect = hasPendingAssets || this.enableCustomFeatures;
|
|
492
494
|
const isDisconnected = !this.wsClient || this.wsClient.readyState !== WebSocket.OPEN;
|
|
493
495
|
|
|
494
|
-
if (
|
|
496
|
+
if (shouldReconnect && isDisconnected && !this.connecting) {
|
|
495
497
|
logger.info({
|
|
496
498
|
message: 'Reconnection check - attempting to reconnect',
|
|
497
499
|
managerId: this.managerId,
|
|
@@ -508,7 +510,7 @@ class WSSubscriptionManager {
|
|
|
508
510
|
/**
|
|
509
511
|
* Establish the WebSocket connection.
|
|
510
512
|
*/
|
|
511
|
-
|
|
513
|
+
public async connect(): Promise<void> {
|
|
512
514
|
if (this.connecting) {
|
|
513
515
|
return;
|
|
514
516
|
}
|
|
@@ -517,7 +519,9 @@ class WSSubscriptionManager {
|
|
|
517
519
|
}
|
|
518
520
|
|
|
519
521
|
// No assets to subscribe to
|
|
520
|
-
if (this.pendingSubscribeAssetIds.size === 0 &&
|
|
522
|
+
if (this.pendingSubscribeAssetIds.size === 0 &&
|
|
523
|
+
this.subscribedAssetIds.size === 0 &&
|
|
524
|
+
!this.enableCustomFeatures) {
|
|
521
525
|
return;
|
|
522
526
|
}
|
|
523
527
|
|