I'm trying to get a good way of updating the database for my social network when users disconnect, since the user is no longer on the site there scripts can't be activated to update the database, and emit events to other users on the site, so I'm thinking that I need to some how do this on the server itself, rather than relying on the client side scripting.
right now I'm doing something like this on the server side part of the scripting, (which is loaded by the user still)
socket.on('disconnect', function () {
socket.broadcast.emit('disconnect', { data : session});
});
this then triggers the event on the user side scripting again, and it runs an ajax event to update the MYSQL database, and then trigger another socket event to send to the users notifying that this user disconnected, however this only works if the user closes their browser, but not like shut their laptop, or whatever device, and it also relies on being sent to other users for them to handle it, which I can't have happening.
This is troubling me very much, I need to come up with a solution.