chore: initial commit for phase05

This commit is contained in:
hibna
2026-02-21 16:59:21 +03:00
parent 218452706c
commit 0941a9ba46
43 changed files with 4431 additions and 17 deletions
+30
View File
@@ -0,0 +1,30 @@
import { io, Socket } from 'socket.io-client';
let socket: Socket | null = null;
export function getSocket(): Socket {
if (!socket) {
socket = io('/', {
path: '/socket.io',
auth: {
token: localStorage.getItem('access_token'),
},
autoConnect: false,
});
}
return socket;
}
export function connectSocket() {
const s = getSocket();
if (!s.connected) {
s.auth = { token: localStorage.getItem('access_token') };
s.connect();
}
}
export function disconnectSocket() {
if (socket?.connected) {
socket.disconnect();
}
}