diff --git a/src/client/LobbySocket.ts b/src/client/LobbySocket.ts index 7b71dc21a..4e4922508 100644 --- a/src/client/LobbySocket.ts +++ b/src/client/LobbySocket.ts @@ -18,6 +18,7 @@ export class PublicLobbySocket { private wsConnectionAttempts = 0; private wsAttemptCounted = false; private workerPath: string = ""; + private stopped = true; private readonly reconnectDelay: number; private readonly maxWsAttempts: number; @@ -31,6 +32,7 @@ export class PublicLobbySocket { } async start() { + this.stopped = false; this.wsConnectionAttempts = 0; // Get config to determine number of workers, then pick a random one const config = await getServerConfigFromClient(); @@ -39,6 +41,7 @@ export class PublicLobbySocket { } stop() { + this.stopped = true; this.disconnectWebSocket(); } @@ -96,6 +99,7 @@ export class PublicLobbySocket { } private handleClose() { + if (this.stopped) return; console.log("WebSocket disconnected, attempting to reconnect..."); if (!this.wsAttemptCounted) { this.wsAttemptCounted = true;