TinyBase logoTinyBase β

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
TypeDescription
wsServerWsServer

A reference to the WsServer.

pathIdId

The path that the client joined or left.

clientIdId

The Id of the client being added or removed.

addedOrRemovedIdAddedOrRemoved

Whether the client was added (1) or removed (-1).

returnsvoid

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