import { useRtcStore } from "/@/store/modules/rtc";

const io = (window as any).io as SocketIOClientStatic
let socket: SocketIOClient.Socket

export function createSocket() {
    const rtcStore = useRtcStore()
    console.log('rtcStore', rtcStore)
    const address = import.meta.env.VITE_APP_SOCKET_URL
    socket = io(address, {
        path: "/ws-sync",
        transports: ["websocket"],
    });
    rtcStore.setSocket(socket)
    return socket
}
export function useSocket(): SocketIOClient.Socket {
    return socket
}
