feat: add Socket.IO client and useCallEvents hook for live CTI mode

This commit is contained in:
2026-03-17 09:14:25 +05:30
parent 45bae9c1c0
commit 4f9bdc7312
5 changed files with 381 additions and 30 deletions

22
src/lib/socket.ts Normal file
View File

@@ -0,0 +1,22 @@
import { io, Socket } from 'socket.io-client';
const SIDECAR_URL = import.meta.env.VITE_SIDECAR_URL ?? 'http://localhost:4100';
let socket: Socket | null = null;
export const getSocket = (): Socket => {
if (!socket) {
socket = io(`${SIDECAR_URL}/call-events`, {
autoConnect: false,
transports: ['websocket'],
});
}
return socket;
};
export const disconnectSocket = () => {
if (socket) {
socket.disconnect();
socket = null;
}
};