From 93a60ea1e17dc9ceab28d817c4772d1b6712581e Mon Sep 17 00:00:00 2001 From: Gagan Suie Date: Mon, 6 May 2024 15:47:01 -0500 Subject: [PATCH] Fix: set channel connection to close on destroy --- src/routes/channel/[channelId]/+page.svelte | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/routes/channel/[channelId]/+page.svelte b/src/routes/channel/[channelId]/+page.svelte index 33c99ef0..f06473f1 100644 --- a/src/routes/channel/[channelId]/+page.svelte +++ b/src/routes/channel/[channelId]/+page.svelte @@ -48,7 +48,6 @@ } $: isLive = channel?.videoItems?.some((input: any) => input?.rtmps?.isConnected) ?? false - let wasCloseIntentional = false onMount(async () => { clearInterval(platformPollingInterval) @@ -141,10 +140,10 @@ clearInterval(platformPollingInterval) platformPollingInterval = null disableSharing() - wasCloseIntentional = true channels.forEach((ch: any) => { if (ch.socket && ch.socket.constructor === WebSocket) ch.socket.close() }) + $channel_connection = `closed` channels = [] }) @@ -257,7 +256,7 @@ console.log(data) //if manually closed, don't reconnect - if (wasCloseIntentional) { + if (data.code === 1005) { clearInterval(platformPollingInterval) platformPollingInterval = null return @@ -277,7 +276,6 @@ if (channel) { console.log('Reconnecting to WebSocket...') channel.socket = null - wasCloseIntentional = false // Reset the flag before reconnecting await handleWebsocket() } }, 4000)