From c4b882955301f874f1e5f1115187f4a001b46498 Mon Sep 17 00:00:00 2001 From: Tobias Ollmann Date: Wed, 24 Jan 2024 16:24:55 +0100 Subject: [PATCH 1/2] Fix state handling issue in SignalClient --- src/api/SignalClient.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/api/SignalClient.ts b/src/api/SignalClient.ts index 045b9affb6..3c6bc9a315 100644 --- a/src/api/SignalClient.ts +++ b/src/api/SignalClient.ts @@ -272,7 +272,7 @@ export class SignalClient { abortSignal?.addEventListener('abort', abortHandler); this.log.debug(`connecting to ${url + params}`, this.logContext); if (this.ws) { - await this.close(); + await this.close(false); } this.ws = new WebSocket(url + params); this.ws.binaryType = 'arraybuffer'; @@ -421,10 +421,12 @@ export class SignalClient { this.onClose = undefined; }; - async close() { + async close(updateState: boolean = true) { const unlock = await this.closingLock.lock(); try { - this.state = SignalConnectionState.DISCONNECTING; + if (updateState) { + this.state = SignalConnectionState.DISCONNECTING; + } if (this.ws) { this.ws.onmessage = null; this.ws.onopen = null; @@ -449,7 +451,9 @@ export class SignalClient { this.ws = undefined; } } finally { - this.state = SignalConnectionState.DISCONNECTED; + if (updateState) { + this.state = SignalConnectionState.DISCONNECTED; + } this.clearPingInterval(); unlock(); } From b99d06e4c2047fc9b2a9cb1bf797fc8e7fba7530 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Wed, 24 Jan 2024 16:49:47 +0100 Subject: [PATCH 2/2] Create tall-files-shop.md --- .changeset/tall-files-shop.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tall-files-shop.md diff --git a/.changeset/tall-files-shop.md b/.changeset/tall-files-shop.md new file mode 100644 index 0000000000..9e35d107f4 --- /dev/null +++ b/.changeset/tall-files-shop.md @@ -0,0 +1,5 @@ +--- +"livekit-client": patch +--- + +Fix state handling issue in SignalClient