Skip to content

Commit

Permalink
chore: update socket
Browse files Browse the repository at this point in the history
  • Loading branch information
ynwd committed Nov 17, 2024
1 parent 01dfdd5 commit 5bf2c22
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion modules/hook/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const useWebSocket = (url: string, room: string, user: string) => {
}

console.log(`WebSocket connection closed: ${room}`);
}, 100);
}, 300);
}

const connectWebSocket = () => {
Expand Down Expand Up @@ -70,6 +70,12 @@ const useWebSocket = (url: string, room: string, user: string) => {
console.error("WebSocket error:", error);
// Close the socket on error
socketRef.current?.close();
if (reconnectTimeoutRef.current) {
clearTimeout(reconnectTimeoutRef.current);
setIsConnected(false);
countRef.current = 0;
setMessage("");
}
};
};

Expand Down

0 comments on commit 5bf2c22

Please sign in to comment.