connect-bidi-web
    Preparing search index...

    Interface BidiWebSocketHandler

    interface BidiWebSocketHandler {
        handleConnection(ws: WebSocket): Promise<void>;
        upgrade(
            server:
                | Server<typeof IncomingMessage, typeof ServerResponse>
                | Server<typeof IncomingMessage, typeof ServerResponse>,
            path?: string,
        ): void;
    }
    Index
    • Serves RPCs on an already-accepted WebSocket connection until it closes. Use this if you manage the 'upgrade' event yourself, for example to integrate with a framework that already runs its own ws.WebSocketServer.

      Parameters

      • ws: WebSocket

      Returns Promise<void>

    • Subscribes to server's 'upgrade' event and accepts WebSocket upgrade requests whose path matches path (or the handler's configured path, default "/websocket"), serving any number of concurrent RPCs per accepted connection, demultiplexed by the stream ID on every frame. Upgrade requests for other paths are left untouched, so multiple BidiWebSocketHandlers -- or other 'upgrade' listeners -- can share the same http.Server. Ordinary HTTP requests (the 'request' event) are entirely unaffected.

      Parameters

      • server:
            | Server<typeof IncomingMessage, typeof ServerResponse>
            | Server<typeof IncomingMessage, typeof ServerResponse>
      • Optionalpath: string

      Returns void