Files
knet/js/ws.ts
JurajKubrican 00c209032f game Of Life
2025-03-04 16:31:19 +01:00

8 lines
206 B
TypeScript

const getSocket = (url: string): WebSocket => {
let ws = new WebSocket(url);
ws.onclose = () => setTimeout(() => (ws = getSocket(url)), 100);
ws.onerror = () => ws.close();
return ws;
};