Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Client

Hierarchy

  • EventEmitter
  • EventEmitter
    • Client

Index

Constructors

constructor

Properties

Private channels

channels: {}

Type declaration

connectionState

connectionState: ConnectionState

Private debug

debug: DebugFunc

Private didConnect

didConnect: boolean

Private token

token: string | null

Private ws

ws: __type | null

Static ClientCloseReason

ClientCloseReason: ClientCloseReason = ClientCloseReason

Static defaultMaxListeners

defaultMaxListeners: number

Methods

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • addListener(event: "close", listener: typeof close): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: "close"
    • listener: typeof close

    Returns this

Private cleanupSocket

  • cleanupSocket(): void

close

  • close(): void
  • Closes the connection.

    • If connect was called and not settled it will also reject the promise
    • If there's an open WebSocket connection it will be closed
    • Any open channels or channel requests are closed

    Returns void

connect

  • Connects to the server and primes the client to start sending data

    Parameters

    Returns Promise<void>

    it returns a promise that is resolved when the server is ready (sends cotainer state)

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • emit(event: "close", ...args: Parameters<typeof close>): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

  • Parameters

    • event: "close"
    • Rest ...args: Parameters<typeof close>

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • eventNames(): Array<"close">

getChannel

getMaxListeners

  • getMaxListeners(): number
  • Returns number

getToken

  • getToken(): string | null
  • Gets the token that was used to connect

    Returns string | null

Private handleCloseChannel

Private handleOpenChanRes

  • handleOpenChanRes(channel: Channel, __namedParameters: { error: undefined | null | string; id: undefined | null | number; state: undefined | null | CREATED | ATTACHED | ERROR }): void
  • Parameters

    • channel: Channel
    • __namedParameters: { error: undefined | null | string; id: undefined | null | number; state: undefined | null | CREATED | ATTACHED | ERROR }
      • error: undefined | null | string
      • id: undefined | null | number
      • state: undefined | null | CREATED | ATTACHED | ERROR

    Returns void

isConnected

  • isConnected(): boolean

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: (...args: any[]) => void): this
  • off(event: "close", listener: typeof close): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: "close"
    • listener: typeof close

    Returns this

on

  • on(event: string | symbol, listener: (...args: any[]) => void): this
  • on(event: "close", listener: typeof close): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: "close"
    • listener: typeof close

    Returns this

Private onClose

Private onSocketMessage

  • onSocketMessage(__namedParameters: { data: any }): void
  • Parameters

    • __namedParameters: { data: any }
      • data: any

    Returns void

once

  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • once(event: "close", listener: typeof close): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: "close"
    • listener: typeof close

    Returns this

openChannel

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • prependListener(event: "close", listener: typeof close): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: "close"
    • listener: typeof close

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • prependOnceListener(event: "close", listener: typeof close): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: "close"
    • listener: typeof close

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • removeAllListeners(event?: undefined | "close"): this

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • removeListener(event: "close", listener: typeof close): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Parameters

    • event: "close"
    • listener: typeof close

    Returns this

Private send

setDebugFunc

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

startPing

  • startPing(): void
  • Start a ping<>pong for debugging and latency stats

    Returns void

Private tryConnect

  • tryConnect(__namedParameters: { WebSocketClass: { constructor: any; CLOSED: number; CLOSING: number; CONNECTING: number; OPEN: number; prototype: __type }; polling: boolean; timeout: null | number; token: string; urlOptions: UrlOptions }): Promise<unknown>
  • Parameters

    • __namedParameters: { WebSocketClass: { constructor: any; CLOSED: number; CLOSING: number; CONNECTING: number; OPEN: number; prototype: __type }; polling: boolean; timeout: null | number; token: string; urlOptions: UrlOptions }
      • WebSocketClass: { constructor: any; CLOSED: number; CLOSING: number; CONNECTING: number; OPEN: number; prototype: __type }
        • constructor: function
          • new __type(url: string, protocols?: string | string[]): __type
          • Parameters

            • url: string
            • Optional protocols: string | string[]

            Returns __type

        • Readonly CLOSED: number
        • Readonly CLOSING: number
        • Readonly CONNECTING: number
        • Readonly OPEN: number
        • prototype: __type
      • polling: boolean
      • timeout: null | number
      • token: string
      • urlOptions: UrlOptions

    Returns Promise<unknown>

Static getConnectionStr

  • getConnectionStr(token: string, urlOptions: UrlOptions): string

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc