Cluster supplying the active nodes used to build trees, watched for failures.
Fan-out, per-node viewer capacity, and logging configuration.
Build (or rebuild) the cascade tree for a room and reconcile it against any existing tree.
Computes a fresh plan over the cluster's active nodes, emits CascadeTreeEvent.LinkCreated / CascadeTreeEvent.LinkDropped for the links that changed, updates per-node room tracking, and emits CascadeTreeEvent.LeafAssigned for each seated leaf. If the plan cannot seat every viewer it emits CascadeTreeEvent.CapacityShortfall. Always emits CascadeTreeEvent.TreeBuilt with the final plan.
Identifier of the room the tree serves.
Identifier of the origin (root) node.
Total number of viewers to distribute across the tree.
The computed CascadePlan.
Tear down a room's cascade tree, untracking every participating node and emitting CascadeTreeEvent.LinkDropped for each link followed by CascadeTreeEvent.TreeDropped.
Identifier of the room to detach.
true if the room had a tree, false otherwise.
Detach from cluster failure events. Existing room trees 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 current cascade plan for a room.
Identifier of the room.
The room's CascadePlan, or undefined if no tree exists for it.
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 CascadeTreeEventsThe event name to clear; if omitted, listeners for every event are removed.
This emitter, for chaining.
Builds and maintains per-room cascade fan-out trees over an SfuCluster, scaling a single room's media to a very large viewer population.
For each room it runs planCascadeTree across the cluster's active nodes, then diffs the new plan against the previous one to emit the minimal set of link create/drop events and update per-node room tracking. It watches the cluster through a NodeFailureTracker: when a node that participates in a room's tree fails or is removed, that room's tree is rebuilt automatically.
Emits CascadeTreeEvent events. Pair with a CascadeBridge to realize the tree's links as real inter-node media pipes.
Example
Remarks
Call CascadeTree.dispose to detach from cluster failure events when the tree is no longer needed.