javascript - Disconnect socket.io and send the disconnect reason -
i need disconnect users server using code:
socket.disconnect('user disconnected because of ....');
but when handle disconnect event on user side don't see disconnect reason
socket.on('disconnect', function(reason){ console.log('user 1 disconnected because '+reason); });
i using node server side , browsers client side, idea how send disconnect reason?
it seem there no way such thing can trick using emit function before closing socket
code in server side:
socket.emit('closereason','user disconnected because of ....'); socket.disconnect();
code in client side:
socket.on('closereason',function(reason){ ... });
Comments
Post a Comment