Spaces:
Paused
Paused
| 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; | |
| } | |
| } | |