Socket.io how to handle client internet disconnect event? I read heartbeat on stackoverflow but that solution does not work for me.
I found a ping solution but I think it is a bad approach to ping all the connected user, it will slow down the server
here is my code, kindly guide how to handle internet disconnect event?
io.on('connection', function(client) {
client.on('online', function(data) {
socket_api.user_online(data.user_id, function (err,res){
if (err) {
client.emit ('error',err);
} else {
console.log ("client connected")
client.emit ('online_response', res);
}
});
// client.emit('messages', 'Hello from server');
});
client.on('disconnect', function (data){
console.log ("Client disconnected");
});
});