import io from "socket.io-client";
import { Constants, baseUrls } from "../utils/constants";
import { authSocketService } from "./authSocket";
import { userBalanceSocketService } from "./userBalance";

export let socket: any = null;
export let expertSocket: any = null;
export let matchSocket: any = null;
export let cardSocket: any = null;

export const initialiseSocket = () => {
  // socket = io(baseUrls.socket, {
  //   transports: [`${Constants.WEBSOCKET}`],
  //   auth: {
  //     token: `${sessionStorage.getItem("jwtMaxUser")}`,
  //   },
  // });
  // expertSocket = io(baseUrls.expertSocket, {
  //   transports: [`${Constants.WEBSOCKET}`],
  //   auth: {
  //     token: `${sessionStorage.getItem("jwtMaxUser")}`,
  //   },
  // });
  // matchSocket = io(baseUrls.matchSocket, {
  //   transports: [
  //     process.env.NODE_ENV === "production"
  //       ? `${Constants.POLLING}`
  //       : `${Constants.WEBSOCKET}`,
  //   ],
  // });
  // cardSocket = io(baseUrls.cardSocket, {
  //   transports: [
  //     process.env.NODE_ENV === "production"
  //       ? `${Constants.WEBSOCKET}`
  //       : `${Constants.WEBSOCKET}`,
  //   ],
  // });
};

export const socketService = {
  connect: () => {
    initialiseSocket();
    socket?.connect();
  },
  disconnect: () => {
    socket?.disconnect();
  },
};

