rmapi-js
    Preparing search index...

    Function connectWebSocket

    • open a websocket with the runtime's own WebSocket

      Node, bun and deno send headers with the handshake. A browser cannot, so in a Chrome extension a SocketAuthorization rule is installed first, again on every open so a new session token is picked up, and one handshake at a time so each goes out with its own; in a page, the socket opens without them and the account refuses it.

      No runtime says how a handshake was refused. So when one fails, the host is asked once for the root pointer with the same headers: if it answers 401 the session is refused, and this resolves with that answer, which ends the notifications rather than having the handshake tried again. Anything else rejects, and is tried again.

      Parameters

      • url: string
      • headers: [string, string][]
      • fetch: FetchFunction = ...

        the function that request goes through, the global fetch if omitted

      Returns Promise<PlatformSocket | PlatformResponse>