Spaces:
Paused
Paused
Download client/src/lib/socket.ts from HarshGupta08/watchtorrent: direct link, hf CLI and curl.
- Browser
- Download file 429 Bytes
-
https://huggingface.co/spaces/HarshGupta08/watchtorrent/resolve/main/client/src/lib/socket.ts
- Command line
-
hf download hf://spaces/HarshGupta08/watchtorrent/client/src/lib/socket.ts
-
curl -L -o socket.ts https://huggingface.co/spaces/HarshGupta08/watchtorrent/resolve/main/client/src/lib/socket.ts
429 Bytes
| import { io, Socket } from 'socket.io-client'; | |
| let socket: Socket | null = null; | |
| export function getSocket(): Socket { | |
| if (!socket) { | |
| socket = io('/', { | |
| transports: ['websocket', 'polling'], | |
| reconnection: true, | |
| reconnectionAttempts: 10, | |
| reconnectionDelay: 1000, | |
| }); | |
| } | |
| return socket; | |
| } | |
| export function disconnectSocket() { | |
| if (socket) { | |
| socket.disconnect(); | |
| socket = null; | |
| } | |
| } | |