import { io , Socket } from 'socket.io-client' ; import { socketURL } from '../routes' ; class SocketService { private socket : Socket ; constructor ( ) { this . socket = io ( socketURL ) ; } emitEvent = ( event , payload ) : void => { if ( ! this . socket ) { throw new Error ( 'Socket connection not established' ) ; } this . socket . emit ( event , payload ) ; } ; registerEvent = ( event , callback ) : void => { this . socket . on ( event , callback ) ; } ; } export default new SocketService ( ) ;