From de9edc37d0aeaf461b3c3bc0b322fd7f9a3daf59 Mon Sep 17 00:00:00 2001 From: nuttylmao Date: Wed, 23 Jul 2025 13:48:04 +1000 Subject: [PATCH] Kick connection fixes --- horizontal-chat/script.js | 28 ++++++++++------------------ multichat-overlay/script.js | 28 ++++++++++------------------ multistream-alerts/script.js | 28 ++++++++++------------------ 3 files changed, 30 insertions(+), 54 deletions(-) diff --git a/horizontal-chat/script.js b/horizontal-chat/script.js index 854fc8c..28ce266 100644 --- a/horizontal-chat/script.js +++ b/horizontal-chat/script.js @@ -299,6 +299,12 @@ async function KickConnect() { const websocket = new WebSocket(kickPusherWsUrl); + // Reconnect + websocket.onclose = function () { + console.log(`Reconnecting to ${kickUsername}...`); + setTimeout(connectPusher, 5000); + }; + websocket.onopen = function () { console.log(`Kick successfully conntected to ${kickUsername}.`); } @@ -315,24 +321,10 @@ async function KickConnect() { console.log(`[Pusher] Socket established with ID: ${socketData.socket_id}`); // Now subscribe to a channel - let subscribeMessage = { - event: 'pusher:subscribe', - data: { - channel: `chatroom_${chatroomId}` - } - }; - - websocket.send(JSON.stringify(subscribeMessage)); - - // Now subscribe to a channel - subscribeMessage = { - event: 'pusher:subscribe', - data: { - channel: `chatrooms.${chatroomId}.v2` - } - }; - - websocket.send(JSON.stringify(subscribeMessage)); + websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatroom_${chatroomId}` } })); + websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}` } })); + websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}.v2` } })); + websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `predictions-channel-${chatroomId}` } })); console.log(`[Pusher] Sent subscription request to channel: ${chatroomId}`); } diff --git a/multichat-overlay/script.js b/multichat-overlay/script.js index 53345ea..4fcae0d 100644 --- a/multichat-overlay/script.js +++ b/multichat-overlay/script.js @@ -322,6 +322,12 @@ async function KickConnect() { const websocket = new WebSocket(kickPusherWsUrl); + // Reconnect + websocket.onclose = function () { + console.log(`Reconnecting to ${kickUsername}...`); + setTimeout(connectPusher, 5000); + }; + websocket.onopen = function () { console.log(`Kick successfully conntected to ${kickUsername}.`); } @@ -338,24 +344,10 @@ async function KickConnect() { console.log(`[Pusher] Socket established with ID: ${socketData.socket_id}`); // Now subscribe to a channel - let subscribeMessage = { - event: 'pusher:subscribe', - data: { - channel: `chatroom_${chatroomId}` - } - }; - - websocket.send(JSON.stringify(subscribeMessage)); - - // Now subscribe to a channel - subscribeMessage = { - event: 'pusher:subscribe', - data: { - channel: `chatrooms.${chatroomId}.v2` - } - }; - - websocket.send(JSON.stringify(subscribeMessage)); + websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatroom_${chatroomId}` } })); + websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}` } })); + websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}.v2` } })); + websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `predictions-channel-${chatroomId}` } })); console.log(`[Pusher] Sent subscription request to channel: ${chatroomId}`); } diff --git a/multistream-alerts/script.js b/multistream-alerts/script.js index d8117c1..74f183a 100644 --- a/multistream-alerts/script.js +++ b/multistream-alerts/script.js @@ -320,6 +320,12 @@ async function KickConnect() { const websocket = new WebSocket(kickPusherWsUrl); + // Reconnect + websocket.onclose = function () { + console.log(`Reconnecting to ${kickUsername}...`); + setTimeout(connectPusher, 5000); + }; + websocket.onopen = function () { console.log(`Kick successfully conntected to ${kickUsername}.`); } @@ -336,24 +342,10 @@ async function KickConnect() { console.log(`[Pusher] Socket established with ID: ${socketData.socket_id}`); // Now subscribe to a channel - let subscribeMessage = { - event: 'pusher:subscribe', - data: { - channel: `chatroom_${chatroomId}` - } - }; - - websocket.send(JSON.stringify(subscribeMessage)); - - // Now subscribe to a channel - subscribeMessage = { - event: 'pusher:subscribe', - data: { - channel: `chatrooms.${chatroomId}.v2` - } - }; - - websocket.send(JSON.stringify(subscribeMessage)); + websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatroom_${chatroomId}` } })); + websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}` } })); + websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}.v2` } })); + websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `predictions-channel-${chatroomId}` } })); console.log(`[Pusher] Sent subscription request to channel: ${chatroomId}`); }