R
R
ratatyq2016-12-31 22:32:27
Node.js
ratatyq, 2016-12-31 22:32:27

How to understand who left the site in the socket io library?

Hello, I have a question. I have a site with the socket io library connected, and I need to somehow find out who left the site, how to implement this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
Zakhar Storozhuk, 2016-01-01
@Phell

Assign an ID to each, and handle the disconnect event :)

socket.on('disconnect', function() {
  ....
});

D
de1m, 2016-01-01
@de1m

When connecting, assign an id, something like

io.sockets.on('connection', function (socket) {
     clientid = socket.id;

And when disconnecting, see what id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question