Interfaces

@system-inc/base-foundation · 515c140 · 8 symbols

BaseWebSocket

interface

BaseWebSocket is an interface the combines the libdom WebSocket interface with the Cloudflare WebSocket interface. It is used to provide a common interface for WebSocket connections.

extends WebSocket

Members

  • deserializeAttachment(): any

  • serializeAttachment(attachment: any): void

View source ↗

A mapping from a RequestContextKey to a WebSocketInfoKey.

Modules register these so the framework automatically copies per-request values from the RequestContext into the WebSocketInfo context bag at WebSocket connect time.

Readers on the WebSocket side then pull the value back out with getWsContext(info, wsKey).

Members

// module setup
webSocket: {
    mappings: [
        { rcKey: DeviceIdRequestContextKey, wsKey: DeviceIdWebSocketInfoKey },
    ],
}

View source ↗

Members

View source ↗

extends WebSocketEvent

Members

  • arguments?: any[]

    The arguments that were passed as part of the event. These will be passed to the event handler.

  • errorType: string

    The error that occurred.

  • message?: string

    The error message.

  • origin: string

    The origin of the event.

    This is the worker that the event originated from.

  • originatingType?: string

    The web socket event that was being handled when the error occurred.

  • type: "error"

    Designates this event as an error event.

View source ↗

Members

  • arguments?: any[]

    The arguments that were passed as part of the event. These will be passed to the event handler.

  • origin: string

    The origin of the event.

    This is the worker that the event originated from.

  • type: string

    The type of the event. This determines how the event should be handled.

  • static isWebSocketErrorEvent(event: WebSocketEvent): event is WebSocketErrorEvent

  • static isWebSocketEvent(event: any): event is WebSocketEvent

  • static isWebSocketForwardingEvent(event: WebSocketEvent): event is WebSocketForwardingEvent

View source ↗

extends WebSocketEvent

Members

  • arguments?: any[]

    The arguments that were passed as part of the event. These will be passed to the event handler.

  • origin: string

    The origin of the event.

    This is the worker that the event originated from.

  • originatingType: string

    The event that is being forwarded.

  • rpcEndpoint?: string

    The rpc endpoint on the target.

  • target: string

    The target of the event.

    This is the worker that the event is being forwarded to.

  • type: "forwarding"

    Designates this event as a forwarding event.

View source ↗

WebSocketInfo

interface

Information about a WebSocket connection that is carried alongside every message and across workers / durable objects.

Values written to context must be JSON-serializable since WebSocketInfo is serialized on the wire. Write and read through getWsContext and setWsContext using typed WebSocketInfoKeys.

extends JsonObject

Members

  • context: JsonObject

  • path: string

  • socketId: string

View source ↗

Members

  • delegates: WebSocketDelegateSettings[]

  • mappings?: (WebSocketContextMapping<Json>)[]

    RC → WS key mappings aggregated across all modules. Applied to WebSocketInfo.context at connect time.

    Populated from module settings via BaseAppManifest; app code generally does not need to set this directly.

View source ↗