Skip to content

How to disconnect all connected clients ? #314

Answered by Totodore
Axnjr asked this question in Q&A
Discussion options

You must be logged in to vote

What do you mean by "active" and "inactive"? If it is simply clients that are not reachable due to a network bug there is already a mechanism for that and the socket will be disconnected.
If it is a "state" change then you should simply emit an event to notify the server rather than emiting "BEAT" events. Once you receive this particular state you can add the socket to the room of your choice:
https://docs.rs/socketioxide/latest/socketioxide/handler/extract/struct.SocketRef.html#method.join

Later you can apply any operation on the sockets in the given room, for example disconnect the socket, or make them join another room, or remove them from a room:
https://docs.rs/socketioxide/latest/so…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Axnjr
Comment options

Answer selected by Totodore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants