papi-dts
    Preparing search index...

    Manages the JSON-RPC protocol on the server end of a websocket owned by main. This class is not intended to be instantiated by anything other than RpcWebSocketListener.

    Created by RpcWebSocketListener when a client connects to the web socket server. There is one RpcServer object per client that connects to the web socket server.

    Implements

    Index

    Constructors

    Properties

    connectionStatus: ConnectionStatus

    Whether this connector is setting up or has finished setting up its connection and is ready to communicate on the network

    Methods

    • Sets up the RPC handler by populating connector info, setting up event handlers, and doing one of the following:

      • On clients: connecting to the server
      • On servers: opening an endpoint for clients to connect

      An implementation that opens an endpoint MUST NOT resolve true until that endpoint is actually accepting connections. Callers treat this resolving as permission to start processes that immediately connect, and those clients may get a single attempt with no retry — so reporting ready optimistically surfaces as a client that was refused, whose symptoms appear in a different process entirely. See adr-papi-websocket-hostname-bind.

      Returns Promise<boolean>

      true once the connection is established and usable — for a server, once its endpoint is accepting connections. false if the connection could not be established.

      TODO(PT-4495): implementations disagree on what they return when this handler was already connected or connecting, so a caller can neither rely on that case nor tell a benign double-connect from a real failure. PT-4495 replaces the boolean with a result type that distinguishes the three outcomes; until then, only the two states above are contractual.

    • Disconnects from the connection:

      • On clients: disconnects from the server
      • On servers: disconnects from all clients and closes its connection endpoint

      Returns Promise<void>

    • Sends an event to other processes. Does NOT run the local event subscriptions as they should be run by NetworkEventEmitter after sending on network.

      Type Parameters

      • T

      Parameters

      • eventType: string

        Unique network event type for coordinating between processes

      • event: T

        Event data to emit on the network

      Returns void

    • Send a request and resolve after receiving a response

      Parameters

      • requestType: `${string}:${string}`

        Type of request (or "method" in JSONRPC jargon) to call

      • requestParams: RequestParams

        Parameters associated with this request

      • OptionalskipRetry: boolean

        Whether to skip the retry process that will retry up to 10 times

      Returns Promise<JSONRPCResponse>

      Promise that resolves to a JSONRPCSuccessResponse or JSONRPCErrorResponse message

    • Record how the peer on the other end labels itself, so this socket's log lines can be joined to that process's own. Called remotely by a connecting client; see ANNOUNCE_PEER.

      A socket gets to say this once. Accepting later announcements would let a peer relabel itself mid-session — so log lines already attributed to one name could be continued under another — and would let it re-log this line as often as it liked.

      Parameters

      • peerName: string

        The peer's label for itself

      Returns boolean

      Whether a usable label was recorded