Setu-TS
    Preparing search index...

    Class WebSocketService

    The WebSocket hub.

    0.1.0

    Implements

    Index
    • Creates the service.

      Parameters

      • runtime: IRuntimeServices

        Runtime services (ids, monotonic clock, timers)

      • options: ResolvedOptions

        Resolved plugin options

      • available: boolean

        Whether the HTTP adapter can perform upgrades

      • Optionallogger: ILogger

        Optional logger used to report an upgrade-router failure; the HTTP adapter that consults the router has no logger of its own

      • Optionalbackplane: IRealtimeBackplane

        Optional cross-replica transport. When present, every room broadcast is also published to it; when absent, rooms stay purely in-process, which is the behavior before the backplane existed.

      • Optionalbehaviors: readonly IIngressBehavior[]

        The plugin-level ingress behaviours around onMessage, in declared order. Defaults to none: frame dispatch is then byte-identical to the pre-chain behaviour.

      Returns WebSocketService

    • The router handed to the HTTP adapter. Matches the request against the route table, applies admission control, and builds the sink the adapter binds its native socket into.

      Kept at its public single-parameter shape: the adapter consults it with the native request alone and has no principal to thread, so an adapter-side call routes the upgrade as anonymous. A failure is reported through the logger before it is turned into a 500 refusal, via the same #routeReported wrapper routeUpgrade uses, so the logging behavior has one implementation. The adapter-side UpgradeRouterStore also catches, but it runs inside @setu-ts/runtime, which has no logger and therefore has nowhere to put the cause — so the only place a routing bug can be made visible is here, at its source.

      Returns (request: Request) => Promise<WebSocketUpgradeDecision | null>

      The decision, or null when this is not a WebSocket route

      0.1.0

    • Delivers a frame that arrived from another replica to this replica's local room members.

      Called only by the plugin's backplane subscription. It uses the room registry's local-only delivery path, so an arriving frame is never re-published — which would echo it around the cluster forever.

      Frames of another kind, and frames this instance published itself, are ignored: one backplane topic carries both WebSocket rooms and SSE channels, and a room may legitimately share a name with a channel.

      Parameters

      Returns void

      0.2.0

    • Replaces the plugin-level ingress chain around onMessage with the resolved declared sequence.

      Called once by the plugin's onInit hook, after every RegistryFactory entry of WebSocketPlugin({ behaviors }) has been resolved — the first phase at which the registry holds every capability, and still before the application serves, so no frame is ever dispatched without the final chain. With no factory behaviours configured it is never called with a non-empty list, and frame dispatch keeps the direct, synchronous form.

      Parameters

      • behaviors: readonly IIngressBehavior[]

        The resolved behaviours, in declared order

      Returns void

      0.3.0

    • The upgrade router the kernel terminal handler consults after the middleware pipeline has run without short-circuiting.

      Delegates to the shared #routeReported reporting wrapper: a routing failure is written to the logger here, at its source, before it becomes a refusal. Calling #route directly would make this the one entry point whose failures are invisible — the kernel has no logger to write them to.

      Parameters

      • request: Request

        The native, undisturbed upgrade request

      • Optionalprincipal: IPrincipal

        The authenticated principal, when the middleware pipeline produced one (ctx.request.user). Absent when the upgrade was not authenticated; treated as an anonymous connection, never a failure.

      Returns Promise<WebSocketUpgradeDecision | null>

      The decision, or null when this is not a WebSocket route

      0.3.0