Options
All
  • Public
  • Public/Protected
  • All
Menu

Object to communicate with the websocket

Hierarchy

  • Socket

Index

Methods

  • close(): Promise<void>
  • ping(): Promise<void>
  • setCloseHandler(handler: (error: undefined | Error, code: number, text: string) => void): Promise<void>
  • Allows to provide handler when websocket closing

    Parameters

    • handler: (error: undefined | Error, code: number, text: string) => void

      Receives code status and text received from the peer

        • (error: undefined | Error, code: number, text: string): void
        • Parameters

          • error: undefined | Error
          • code: number
          • text: string

          Returns void

    Returns Promise<void>

  • setMessageHandler(handler: (error: undefined | Error, message: string | Uint8Array) => void): Promise<Cancellable>
  • Allows to listen for a websocket message (there must be only one listener registered per socket for messages to be fully received)

    Parameters

    • handler: (error: undefined | Error, message: string | Uint8Array) => void

      Receives text or data message from websocket and error if occurs (error could be returned if reading from the closed connection)

        • (error: undefined | Error, message: string | Uint8Array): void
        • Parameters

          • error: undefined | Error
          • message: string | Uint8Array

          Returns void

    Returns Promise<Cancellable>

  • setPongHandler(handler: (error: undefined | Error, msg: string) => void): Promise<void>
  • Parameters

    • handler: (error: undefined | Error, msg: string) => void
        • (error: undefined | Error, msg: string): void
        • Parameters

          • error: undefined | Error
          • msg: string

          Returns void

    Returns Promise<void>

  • writeMessage(message: string | Uint8Array): Promise<void>
  • Writes message to a websocket

    Parameters

    • message: string | Uint8Array

      Text or data message

    Returns Promise<void>

Generated using TypeDoc