I have a mobile app which may loose a connection with a server, for instance a network switched from 4g to wifi.In this case it tries 3 times to reconnect with a server. And it usually succeeds.But right now my server always fires the event disconnect and deletes user even if he reconnected.
Right my server side code looks like this:
socket.on('disconnect', function() { deleteUser();});
What I want is if user successfully reconnected, do not delete it.In other words:
socket.on('disconnect', function() { if (user reconnected after n reconnection tries) return; // do not delete deleteUser(); // user didn't reconnect after n tries, delete him.});
But I don't know how to implement this logic on a server.Any advice?