RTCForge API Reference v1.1.1
    Preparing search index...

    Server-side (mediasoup SFU) pool of worker subprocesses. Spawns one worker per logical CPU (by default), tracks each worker's router load, and assigns new routers to the least-loaded worker. Died workers are respawned automatically while the pool is running.

    Node-only; not usable in the browser. Managed internally by MediaService.

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    Methods

    • Closes all workers and empties the pool. Respawning is disabled once closed.

      Returns Promise<void>

    • Creates a mediasoup router on the least-loaded worker, incrementing that worker's load and decrementing it when the router closes.

      Parameters

      • options: RouterOptions

        mediasoup router options (media codecs).

      Returns Promise<Router<AppData>>

      The created mediasoup Router.

      If the pool has not been started, or if it has no workers.

    • Synchronously invokes every listener registered for event, in registration order.

      Type Parameters

      • K extends keyof WorkerPoolEvents

      Parameters

      • event: K

        The event name to emit.

      • ...args: WorkerPoolEvents[K]

        The argument tuple to pass to each listener, matching Events[event].

      Returns boolean

      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).

    • Returns the number of listeners currently registered for event.

      Type Parameters

      • K extends keyof WorkerPoolEvents

      Parameters

      • event: K

        The event name to count listeners for.

      Returns number

      The count of registered listeners (0 if none).

    • Removes a previously registered listener for event.

      Type Parameters

      • K extends keyof WorkerPoolEvents

      Parameters

      • event: K

        The event name the listener was registered for.

      • listener: (...args: WorkerPoolEvents[K]) => void

        The exact function reference passed to on or once.

      Returns this

      This emitter, for chaining.

      If the listener is not currently registered, this is a no-op. Only the first matching registration is removed.

    • Registers a listener that is invoked every time event is emitted.

      Type Parameters

      • K extends keyof WorkerPoolEvents

      Parameters

      • event: K

        The event name to listen for.

      • listener: (...args: WorkerPoolEvents[K]) => void

        Callback invoked with the event's argument tuple.

      Returns this

      This emitter, for chaining.

    • Registers a listener that is invoked at most once: it is removed automatically before being called the first time event is emitted.

      Type Parameters

      • K extends keyof WorkerPoolEvents

      Parameters

      • event: K

        The event name to listen for.

      • listener: (...args: WorkerPoolEvents[K]) => void

        Callback invoked with the event's argument tuple on the next emission.

      Returns this

      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.

      Parameters

      • Optionalevent: keyof WorkerPoolEvents

        The event name to clear; if omitted, listeners for every event are removed.

      Returns this

      This emitter, for chaining.

    • Spawns the configured number of workers. Idempotent and safe against concurrent calls; returns once all workers are ready.

      Returns Promise<void>