I'm writing an application where I open up a socket when a user visits my site, record information by sending data over the socket while the user is on the site, and store the information in a database once the user leaves the site.
The problem I am currently facing is that while I can detect when a socket disconnects from my server, I don't know which socket corresponds to what information, so I don't know what information to store into the database.
Below is where I believe I need to put in code
socket.on('disconnect',function() {
//insert data corresponding to current socket into database
console.log('The client has disconnected!');
});
Thanks!