mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage
synced 2026-04-12 02:38:15 +00:00
feat: add Socket.IO client and useCallEvents hook for live CTI mode
This commit is contained in:
22
src/lib/socket.ts
Normal file
22
src/lib/socket.ts
Normal 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;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user