Open einargs opened 1 year ago
The website uses an effect to setup a websocket that will connect to the server. This could also be combined with the code to receive the chatlog.
See the socket.js file in the audio team repo for more information.
export function useSocket() { const [isConnected, setIsConnected] = useState(socket.connected); useEffect(() => { function onConnect() { setIsConnected(true); } function onDisconnect() { setIsConnected(false); } socket.on('connect', onConnect); socket.on('disconnect', onDisconnect); return () => { socket.off('connect', onConnect); socket.off('disconnect', onDisconnect); }; }, []); return [isConnected] }
The website uses an effect to setup a websocket that will connect to the server. This could also be combined with the code to receive the chatlog.
See the socket.js file in the audio team repo for more information.