Reputation: 3
I'm using node js and socket.io, I need to manage the users when they leave from application, what is the best practice to do this?
Upvotes: 0
Views: 49
Reputation: 1346
Try this:
io.sockets.on('connection', function (socket) {
socket.on('disconnect', function () {
console.log(socket.id);
});
socket.on('connect', function () {
console.log(socket.id);
});
});
You can get the socket.id when users enter and leave from your app. I hope it is useful
Upvotes: 1