Automerge Repo - v2.6.0-alpha.2
    Preparing search index...

    Class WebSocketClientAdapter

    Hierarchy

    • WebSocketNetworkAdapter
      • WebSocketClientAdapter
    Index

    Constructors

    • Parameters

      • url: string
      • OptionalretryInterval: number

      Returns WebSocketClientAdapter

    Properties

    onClose: () => void
    onError: () => void

    Native WebSocket error events are intentionally opaque — on both the browser and Node the error detail is withheld from scripts by design (https://stackoverflow.com/a/31003057/239663) — so we just log and let the retry logic reconnect.

    onMessage: (event: MessageEvent) => void
    onOpen: () => void
    peerId?: PeerId
    peerMetadata?: PeerMetadata
    remotePeerId?: PeerId
    retryInterval: number
    socket?: WebSocket
    url: string
    prefixed: string | boolean

    Methods

    • Called by the Repo to start the connection process

      Parameters

      • peerId: PeerId

        the peerId of this repo

      • OptionalpeerMetadata: PeerMetadata

        how this adapter should present itself to other peers

      Returns void

    • Called by the Repo to disconnect from the network

      Returns void

    • Return an array listing the events for which the emitter has registered listeners.

      Returns (keyof NetworkAdapterEvents)[]

    • Returns boolean

    • Returns void

    • Return the number of listeners listening to a given event.

      Parameters

      Returns number

    • Return the listeners registered for a given event.

      Type Parameters

      Parameters

      • event: T

      Returns (
          (
              ...args: ArgumentMap<NetworkAdapterEvents>[Extract<
                  T,
                  keyof NetworkAdapterEvents,
              >],
          ) => void
      )[]

    • Parameters

      Returns void

    • Parameters

      • messageBytes: Uint8Array

      Returns void

    • Remove all listeners, or those of the specified event.

      Parameters

      • Optionalevent: keyof NetworkAdapterEvents

      Returns this

    • Remove the listeners of a given event.

      Type Parameters

      Parameters

      Returns this

    • Called by the Repo to send a message to a peer

      Parameters

      Returns void

    • Returns Promise<void>