I have a socket.io application
with node.js
and was wondering what possibilities exist to respond to a client simply closing their browser window. Is there anyway to know that this has been done? What kinda of signal can been sent to the server?
If I don't have a way of doing telling if a particular client has disconnected what else can I do?
Your socket on the node.js side will receive a "disconnect" event when the browser closes the connection, which you can then react to.
When a client closes their browser window, socket.io fires a special 'disconnect' event.
Assuming you've required socket.io in your node server file
then you can listen for the 'disconnect' event fired by each socket:
Note - socket here is given by:
source: http://socket.io/get-started/chat/
You want to fire a message over your socket in an unload trigger.
Or whatever you call your hook.