import { io } from 'socket.io-client';
import { workerSocketUrl } from '@/config/env';

/**
 *
 * @returns {SocketClient}
 */
export const workerConnect = () => {
  return io(workerSocketUrl, {
    transports: ['websocket'],
    reconnectionAttempts: 5,
    reconnectionDelay: 2000,
  });
};

export const workerEvent = {
  connect: 'connect',
  disconnected: 'disconnected',
  fetchUrlWorkerId: 'fetch-url-worker-id',
  fetchUrlJobRequest: 'fetch-url-job-request',
  fetchUrlJobRecived: 'fetch-url-job-recived',
  workerSetIndentify: 'worker-set-indentify',
  workerReadyUp: 'worker-ready-up',
  workerReadyDown: 'worker-ready-down',
};
