import { io } from 'socket.io-client';
import { Socket } from 'socket.io-client/build/esm/socket'
// 设置socket链接
export const socketInit = (enableWebsocket: boolean) => {
  // const socketUrl = import.meta.env.VITE_SOCKET_URL;

  const _socket: Socket = io(undefined, {
    reconnection: true,
    reconnectionDelay: 1000,
    reconnectionDelayMax: 5000,
    randomizationFactor: 0.5,
    path: '/ws/socket.io',
    transports: enableWebsocket ? ['websocket'] : ['polling', 'websocket'],
    auth: { token: localStorage.token }
  });
  console.log('_socket', _socket)
  return _socket
}

