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

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -