Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WebsocketService

Hierarchy

  • WebsocketService

Index

Properties

Private appId

appId: string

The app ID of transfers we want to receive notifications for

Private eventListener

eventListener: Function

The callback for websocket events

Private globalSocket

globalSocket: WebSocket

The main websocket connection to Aspera Browser

Private initPromise

initPromise: PromiseObject = generatePromiseObjects()

Global promise object that resolves when init completes

Private isConnected

isConnected: boolean = false

Indicator if the websocket is already connected

Private sockets

sockets: Map<WebsocketTopics, Function> = new Map()

A map of requested subscription names and the callback for them

Methods

Private connect

  • connect(): void

Private getWebSocketConnection

  • getWebSocketConnection(startPort: number, endPort: number): Promise<WebSocket>
  • Parameters

    • startPort: number
    • endPort: number

    Returns Promise<WebSocket>

Private handleClose

  • handleClose(): void
  • This function handles completed subscription

    Returns void

Private handleError

  • handleError(): void
  • This function handles errors received from the websocket

    Returns void

Private handleMessage

  • handleMessage(message: MessageEvent<string>): void
  • This function handles messages received from the websocket

    Parameters

    • message: MessageEvent<string>

    Returns void

Private handleNotReady

  • handleNotReady(): void

Private handleOpen

  • handleOpen(): void
  • This function handles when a connection is opened

    Returns void

init

  • init(): Promise<unknown>
  • This function starts the websocket subscription with the websocket provider

    Returns Promise<unknown>

    a promise that resolves when the websocket connection is established

Private joinChannel

  • joinChannel(): boolean
  • This function joins the channel to be able to subscribe to events

    Returns boolean

Private notifyEvent

Private reconnect

  • reconnect(): void

registerEvent

  • registerEvent(callback: Function): void
  • Parameters

    • callback: Function

      the callback function to call with the event name.

    Returns void

registerMessage

  • This function registers clients to listen to a certain message name. Returns any to allow functions to declare proper type

    Parameters

    • messageName: WebsocketTopics

      the name of messages to listen to (one message name per subscription)

    • callback: Function

      the callback function

    Returns void

Private updateRpcPort

  • updateRpcPort(): void