()
| 8 | }; |
| 9 | |
| 10 | export const useSocket = () => { |
| 11 | const [socket, setSocket] = useState<WebSocket | null>(null); |
| 12 | // const user = useUser(); |
| 13 | |
| 14 | useEffect(() => { |
| 15 | const ws = new WebSocket(`${WS_URL}?token=${user.token}`); |
| 16 | |
| 17 | ws.onopen = () => { |
| 18 | setSocket(ws); |
| 19 | }; |
| 20 | |
| 21 | ws.onclose = () => { |
| 22 | setSocket(null); |
| 23 | }; |
| 24 | |
| 25 | return () => { |
| 26 | ws.close(); |
| 27 | }; |
| 28 | }, [user]); |
| 29 | |
| 30 | return socket; |
| 31 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected