Setu-TS
    Preparing search index...

    Interface IWebSocketConnection

    A live WebSocket connection, as seen by application code.

    0.2.0

    interface IWebSocketConnection {
        data: Map<string, unknown>;
        id: string;
        isOpen: boolean;
        path: string;
        readyState: WebSocketReadyState;
        close(code?: number, reason?: string): void;
        send(data: string | Uint8Array<ArrayBufferLike>): void;
        sendJson<T>(payload: T): void;
    }

    Implemented by

    Index
    data: Map<string, unknown>

    Per-connection application state, the socket-lifetime analogue of IRequestContext.state. Use it to attach an authenticated user id, a tenant, or any value later handlers and broadcasts need.

    id: string

    Unique connection ID (from runtime.uuid()).

    isOpen: boolean

    Whether the connection is still writable.

    path: string

    The path this connection was opened on.

    Current lifecycle state.

    • Closes the connection. Idempotent.

      Parameters

      • Optionalcode: number

        RFC 6455 close code (defaults to 1000)

      • Optionalreason: string

        Human-readable close reason

      Returns void

    • Sends a frame to this peer.

      Parameters

      • data: string | Uint8Array<ArrayBufferLike>

        Text as string, binary as Uint8Array

      Returns void

      If the connection is no longer open

    • Serializes a value to JSON and sends it as a text frame.

      Type Parameters

      • T

        The payload type

      Parameters

      • payload: T

        The value to serialize

      Returns void

      If the connection is no longer open