A
A
Alexander Bublikov2017-01-12 22:21:18
Node.js
Alexander Bublikov, 2017-01-12 22:21:18

How to disconnect socket from server side by socket.id?

Good afternoon, please tell me how to execute the "disconnect ()" function but for a specific user, by socket.id .

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2017-01-12
@bublik462

var clients = io.sockets.clients();
var clients = io.sockets.clients('room'); // all users from room `room`

  • get a list of clients.
  • iterate over to find the desired id
  • disconnect
  • ...
  • profit

A
Alexander Bublikov, 2017-01-12
@bublik462

Thank you, of course, but I need socket.id for a specific one. everything was stated in the question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question