@neta-art/cohub 5.4.2 → 5.4.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.
|
@@ -4081,6 +4081,7 @@ declare class WebsocketClient {
|
|
|
4081
4081
|
private authenticate;
|
|
4082
4082
|
private flushRoomSubscriptions;
|
|
4083
4083
|
private restoreRoomSubscriptions;
|
|
4084
|
+
private resetRoomSubscriptions;
|
|
4084
4085
|
private createAuthWaiter;
|
|
4085
4086
|
private resolveAuthWaiter;
|
|
4086
4087
|
private rejectAuthWaiter;
|
package/dist/chunks/websocket.js
CHANGED
|
@@ -226,6 +226,7 @@ var WebsocketClient = class {
|
|
|
226
226
|
this.startPingLoop();
|
|
227
227
|
await this.authenticate();
|
|
228
228
|
this.state = "open";
|
|
229
|
+
this.restoreRoomSubscriptions();
|
|
229
230
|
this.reconnectAttempt = 0;
|
|
230
231
|
this.emit("open", { connectionId: this.connectionId });
|
|
231
232
|
resolveOnce();
|
|
@@ -261,6 +262,7 @@ var WebsocketClient = class {
|
|
|
261
262
|
this.ws = null;
|
|
262
263
|
this.compactStreamContexts.clear();
|
|
263
264
|
this.patchStreamBuffers.clear();
|
|
265
|
+
this.resetRoomSubscriptions();
|
|
264
266
|
const closeError = new Error(formatCloseMessage(event.code, event.reason));
|
|
265
267
|
this.rejectAuthWaiter(closeError);
|
|
266
268
|
const retryAuthClose = event.code === AUTH_CLOSE_CODE && this.retryAuthClose;
|
|
@@ -297,10 +299,7 @@ var WebsocketClient = class {
|
|
|
297
299
|
this.retryAuthClose = false;
|
|
298
300
|
this.compactStreamContexts.clear();
|
|
299
301
|
this.patchStreamBuffers.clear();
|
|
300
|
-
|
|
301
|
-
state.subscribed = false;
|
|
302
|
-
state.pending = false;
|
|
303
|
-
}
|
|
302
|
+
this.resetRoomSubscriptions();
|
|
304
303
|
}
|
|
305
304
|
async updatePresence(input) {
|
|
306
305
|
await this.ensureOpen();
|
|
@@ -477,11 +476,10 @@ var WebsocketClient = class {
|
|
|
477
476
|
}
|
|
478
477
|
});
|
|
479
478
|
await waiter.promise;
|
|
480
|
-
await this.restoreRoomSubscriptions();
|
|
481
479
|
this.authReconnectAttempted = false;
|
|
482
480
|
}
|
|
483
481
|
flushRoomSubscriptions() {
|
|
484
|
-
if (this.ws?.readyState !== WebSocket.OPEN) return;
|
|
482
|
+
if (this.state !== "open" || this.ws?.readyState !== WebSocket.OPEN) return;
|
|
485
483
|
const rooms = [...this.roomSubscriptions.entries()].filter(([, state]) => state.refCount > 0 && !state.subscribed && !state.pending).map(([room]) => room);
|
|
486
484
|
if (rooms.length === 0) return;
|
|
487
485
|
this.send({
|
|
@@ -493,10 +491,16 @@ var WebsocketClient = class {
|
|
|
493
491
|
if (state) state.pending = true;
|
|
494
492
|
}
|
|
495
493
|
}
|
|
496
|
-
|
|
497
|
-
|
|
494
|
+
restoreRoomSubscriptions() {
|
|
495
|
+
this.resetRoomSubscriptions();
|
|
498
496
|
this.flushRoomSubscriptions();
|
|
499
497
|
}
|
|
498
|
+
resetRoomSubscriptions() {
|
|
499
|
+
for (const state of this.roomSubscriptions.values()) {
|
|
500
|
+
state.subscribed = false;
|
|
501
|
+
state.pending = false;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
500
504
|
createAuthWaiter() {
|
|
501
505
|
this.rejectAuthWaiter(/* @__PURE__ */ new Error("superseded auth waiter"));
|
|
502
506
|
let resolve;
|
package/dist/index.js
CHANGED