Cluster whose nodes are assigned to rooms and watched for failures.
Optional logging configuration.
Number of rooms with a primary node assignment.
Attach a room to an SFU node, or extend it with a cascade link.
On first attach the room is assigned a primary node and CascadingRouterEvent.RoomAssigned is emitted. On subsequent attaches that resolve to a different node, that node is added as a cascade link and CascadingRouterEvent.CascadeCreated is emitted (once per distinct node). Attaches that resolve to an already-linked node are no-ops.
Identifier of the room to attach.
OptionalpreferredRegion: stringOptional region hint passed to the placement strategy.
The node selected for this attach (primary on first call, cascade target otherwise).
NoAvailableNodeError when the cluster has no active node to assign.
Detach a room from the SFU entirely, releasing its primary node and every cascade link. Emits CascadingRouterEvent.RoomDetached.
Identifier of the room to detach.
true if the room was attached, false otherwise.
Detach from cluster failure events. Existing assignments are left intact.
Synchronously invokes every listener registered for event, in registration order.
true if at least one listener was invoked, false if there were none.
The listener list is snapshotted before dispatch, so mutations made by handlers take effect only on subsequent emissions. Listeners are isolated: if one throws, the remaining listeners still run and the error is surfaced via console.error rather than swallowed silently (consistent with LocalMessageBus).
Get the primary node currently assigned to a room.
Identifier of the room.
The primary node, or undefined if the room is not attached.
Get the cascade nodes (beyond the primary) currently serving a room.
Identifier of the room.
A copy of the room's cascade node list (empty if none).
Returns the number of listeners currently registered for event.
The event name to count listeners for.
The count of registered listeners (0 if none).
Registers a listener that is invoked at most once: it is removed automatically before
being called the first time event is emitted.
This emitter, for chaining.
Remove a pending one-time listener by passing the same function reference to off.
Removes listeners for a single event, or for all events.
Optionalevent: keyof CascadingRouterEventsThe event name to clear; if omitted, listeners for every event are removed.
This emitter, for chaining.
Assigns rooms to SFU nodes and grows per-room cascades across additional nodes on top of an SfuCluster.
Each room gets one primary node via the cluster's placement strategy. When a room is attached again and placement resolves to a different node, that node is added as a cascade link — letting a single room span multiple SFUs (for example across regions). The router watches the cluster through a NodeFailureTracker: when a node fails or is removed, its room assignments are cleared and its cascade links dropped, emitting the corresponding detach and drop events.
Emits CascadingRouterEvent events. Pair with an SfuBridge to apply these decisions onto a concrete media plane.
Example
Remarks
Call CascadingRouter.dispose to detach from cluster events when the router is no longer needed.