ClientIdsListener
The ClientIdsListener type describes a function that is used to listen to clients joining and leaving the active paths that a WsServer is handling.
(
wsServer: WsServer,
pathId: Id,
clientId: Id,
addedOrRemoved: IdAddedOrRemoved,
): void| Type | Description | |
|---|---|---|
wsServer | WsServer | A reference to the |
pathId | Id | The path that the client joined or left. |
clientId | Id | The |
addedOrRemoved | IdAddedOrRemoved | Whether the client was added ( |
| returns | void | This has no return value. |
A WsServer listens to any path, allowing an app to have the concept of distinct 'rooms' that only certain clients are participating in. As soon as a new client connects to a path, this listener will be called with the Id of the path, the Id of the new client, and an addedOrRemoved value of 1.
When the client disconnects from a path, it will be called again with the Id of the path, the Id of the leaving client, and an addedOrRemoved value of -1.
A ClientIdsListener is provided when using the addClientIdsListener method. See that method for specific examples.
Since
v5.0.3