Interface Sockets

Interface for socket connection management functionality

interface Sockets {
    kernel: Kernel;
    all(): Map<string, SocketConnection>;
    close(id: string): Promise<void>;
    createWebSocket(
        url: string,
        options?: { protocols?: string | string[] },
    ): Promise<WebSocketConnection>;
    createWebTransport(
        url: string,
        options?: { allowPooling?: boolean },
    ): Promise<WebTransportConnection>;
    get(id: string): undefined | SocketConnection;
}

Properties

kernel: Kernel

Get the kernel instance

Methods

  • Create a new WebSocket connection

    Parameters

    • url: string

      WebSocket URL (ws:// or wss://)

    • Optionaloptions: { protocols?: string | string[] }

      Optional WebSocket configuration

    Returns Promise<WebSocketConnection>

    Promise that resolves to the WebSocket connection

  • Create a new WebTransport connection

    Parameters

    • url: string

      WebTransport URL (https://)

    • Optionaloptions: { allowPooling?: boolean }

      Optional WebTransport configuration

    Returns Promise<WebTransportConnection>

    Promise that resolves to the WebTransport connection