import handleSocketUserEnter from './handleSocketUserEnter' ; import handleSocketUserExit from './handleSocketUserExit' ; export default function handleSocket ( peerConnection ) { peerConnection . socket . removeAllListeners ( ) ; peerConnection . socket . on ( 'disconnect' , ( ) => { peerConnection . selfDestroy ( ) ; } ) ; peerConnection . socket . on ( 'connect' , ( ) => { } ) ; peerConnection . socket . on ( 'USER_ENTER' , ( payload ) => { handleSocketUserEnter ( peerConnection , payload ) ; } ) ; peerConnection . socket . on ( 'USER_EXIT' , ( ) => { handleSocketUserExit ( peerConnection ) ; } ) ; peerConnection . socket . on ( 'ENCRYPTED_MESSAGE' , ( payload ) => { peerConnection . receiveEncryptedMessage ( payload ) ; } ) ; peerConnection . socket . on ( 'USER_DISCONNECT' , ( ) => { peerConnection . toggleLockRoom ( false ) ; } ) ; }