-
I'm working on a project where in I want to disconnect all connected clients at once by emitting a Is there any better approach to handle inactive clients ?Is there a built-in method or recommended pattern for achieving this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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. 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: |
Beta Was this translation helpful? Give feedback.
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…