8 lines
206 B
TypeScript
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;
|
|
}; |