I have a Node server with SocketIO and several connections. How is it possible to disconnect an existing socket based on its ID? There are rooms, an admin in each room and other connections. My goal is to enable the admin socket to make any other socket disconnect based on its ID.
A workaround would be to send a message to the client-to-be-kicked to ping the server back: io.to(socketId).emit('commit-suicide!');
, then it sends back an "I-am-so-suicid"
message and the server calls socket.disconnect()
. Now this is clearly not the optimal solution...