Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WsEndpoint

WebSocket connection to Chronik.

Hierarchy

  • WsEndpoint

Index

Constructors

Properties

autoReconnect: boolean

Whether to automatically reconnect on disconnect, default true.

onConnect?: (e: Event) => void

Type declaration

    • (e: Event): void
    • Fired when a connection has been (re)established.

      Parameters

      • e: Event

      Returns void

onEnd?: (e: Event) => void

Type declaration

    • (e: Event): void
    • Fired after a connection has been manually closed, or if autoReconnect is false, if the WebSocket disconnects for any reason.

      Parameters

      • e: Event

      Returns void

onError?: (e: ErrorEvent) => void

Type declaration

    • (e: ErrorEvent): void
    • Fired when an error with the WebSocket occurs.

      Parameters

      • e: ErrorEvent

      Returns void

onMessage?: (msg: SubscribeMsg) => void

Type declaration

onReconnect?: (e: Event) => void

Type declaration

    • (e: Event): void
    • Fired after a connection has been unexpectedly closed, and before a reconnection attempt is made. Only fired if autoReconnect is true.

      Parameters

      • e: Event

      Returns void

Methods

  • close(): void
  • Close the WebSocket connection and prevent future any reconnection attempts.

    Returns void

  • subscribe(scriptType: ScriptType, scriptPayload: string): void
  • Subscribe to the given script type and payload. For "p2pkh", scriptPayload is the 20 byte public key hash.

    Parameters

    Returns void

  • unsubscribe(scriptType: ScriptType, scriptPayload: string): void
  • Unsubscribe from the given script type and payload.

    Parameters

    Returns void

  • waitForOpen(): Promise<void>
  • Wait for the WebSocket to be connected.

    Returns Promise<void>

Generated using TypeDoc