TinyBase logoTinyBase β

PathIdsListener

The PathIdsListener type describes a function that is used to listen to changes of active paths that a WsServer is handling.

(
  wsServer: WsServer,
  pathId: Id,
  addedOrRemoved: IdAddedOrRemoved,
): void
TypeDescription
wsServerWsServer

A reference to the WsServer.

pathIdId

The Id of the path being added or removed.

addedOrRemovedIdAddedOrRemoved

Whether the path 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 single client connects to a new path, this listener will be called with the Id of the new path and an addedOrRemoved value of 1.

When the final client disconnects from a path, it will be called again with the Id of the deactivated path and an addedOrRemoved value of -1.

A PathIdsListener is provided when using the addPathIdsListener method. See that method for specific examples.

Since

v5.0.3