From c70555e2041b982a08cb3e63df6fd5fb9076097a Mon Sep 17 00:00:00 2001 From: ynwd <10122431+ynwd@users.noreply.github.com> Date: Fri, 1 Nov 2024 05:00:46 +0700 Subject: [PATCH] chore: update socket hook --- modules/hook/socket.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/hook/socket.ts b/modules/hook/socket.ts index 32b59722..091a0a4c 100644 --- a/modules/hook/socket.ts +++ b/modules/hook/socket.ts @@ -10,6 +10,10 @@ const useWebSocket = (url: string, room: string) => { const connectWebSocket = () => { socketRef.current = new WebSocket(url); + console.log(socketRef.current); + if (socketRef.current.readyState !== WebSocket.OPEN) { + setIsConnected(false); + } socketRef.current.onopen = () => { setIsConnected(true);