socketio / socket.io-redis-emitter

The Socket.IO Redis emitter, allowing to communicate with a group of Socket.IO servers from another Node.js process.
https://socket.io/docs/v4/redis-adapter/
MIT License
722 stars 121 forks source link

How do you remoteDisconnect? #90

Closed Bioblaze closed 3 years ago

Bioblaze commented 3 years ago

Is there a way to Trigger a Remote Disconnect on the Servers?

darrachequesne commented 3 years ago

Added in @socket.io/redis-emitter@4.0.0 (https://github.com/socketio/socket.io-emitter/commit/a70db12877d901dd0f7085def0a91145b7c83163)

Syntax:

// make all Socket instances disconnect
io.disconnectSockets();

// make all Socket instances of the "admin" namespace in the "room1" room disconnect
io.of("/admin").in("room1").disconnectSockets();

// this also works with a single socket ID
io.of("/admin").in(theSocketId).disconnectSockets();