Make client disconnect message on node.js tab

I am creating a multiplayer game with a node.js server with socket.io and an html5 canvas with a js file in it for the client.

Now I have it socket.on('disconnect',function(){my code here}); on the server, but when the user closes the tab in which the client is working, it does not trigger any disconnect event on the server, but I need the server to notice when the user closes the tab.

How can I get the client to fire the event correctly when he closes the tab in which he is working?

+3
source share
1 answer

, . - , . "ping", , .;) ?

+2

All Articles