How do I disable all socket.io enabled sockets?
2 answers
Assuming io
is your socket.io server object, you can do this from the server side to disconnect all currently connected clients:
io.sockets.sockets.forEach(function(s) {
s.disconnect(true);
});
Clients may try to reconnect, depending on the client configuration.
FYI, there are many different answers to similar problems in this question: Socket.IO - how do I get a list of connected sockets / clients? but you should only pay attention to the answers that refer to versions of socket.io greater than 1.0, since this all changed with v1.0.
+3
source to share