Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: set channel connection to close on destroy #1237

Merged
merged 1 commit into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/routes/channel/[channelId]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
}

$: isLive = channel?.videoItems?.some((input: any) => input?.rtmps?.isConnected) ?? false
let wasCloseIntentional = false

onMount(async () => {
clearInterval(platformPollingInterval)
Expand Down Expand Up @@ -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 = []
})

Expand Down Expand Up @@ -257,7 +256,7 @@
console.log(data)

//if manually closed, don't reconnect
if (wasCloseIntentional) {
if (data.code === 1005) {
clearInterval(platformPollingInterval)
platformPollingInterval = null
return
Expand All @@ -277,7 +276,6 @@
if (channel) {
console.log('Reconnecting to WebSocket...')
channel.socket = null
wasCloseIntentional = false // Reset the flag before reconnecting
await handleWebsocket()
}
}, 4000)
Expand Down