Class client

Hierarchy

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(clientConfig?: IClientConfig): client

Parameters

Returns

client

Properties

public origin: string

public protocols: Array<string>

public response: ClientResponse

public secure: boolean

public socket: Socket

public url: Url

Methods

public addListener(event: string, listener: () => void): client

Parameters

  • event: string
  • listener: () => void

Returns

client

public addListener(event: "'connect'", cb: (connection: "websocket".connection) => void): client

Parameters

  • event: "'connect'"
  • cb: (connection: "websocket".connection) => void

Returns

client

public addListener(event: "'connectFailed'", cb: (err: Error) => void): client

Parameters

  • event: "'connectFailed'"
  • cb: (err: Error) => void

Returns

client

public connect(requestUrl: Url, protocols?: Array<string>, origin?: string, headers?: Array<any>)

Establish a connection. The remote server will select the best subprotocol that it supports and send that back when establishing the connection.

Parameters

  • requestUrl: Url

    should be a standard websocket url

  • protocols?: Array<string> optional
  • origin?: string optional
  • headers?: Array<any> optional

public connect(requestUrl: string, protocols?: Array<string>, origin?: string, headers?: Array<any>)

Parameters

  • requestUrl: string
  • protocols?: Array<string> optional
  • origin?: string optional
  • headers?: Array<any> optional

public connect(requestUrl: Url, protocols?: string, origin?: string, headers?: Array<any>)

Parameters

  • requestUrl: Url
  • protocols?: string optional
  • origin?: string optional
  • headers?: Array<any> optional

public connect(requestUrl: string, protocols?: string, origin?: string, headers?: Array<any>)

Parameters

  • requestUrl: string
  • protocols?: string optional
  • origin?: string optional
  • headers?: Array<any> optional

public emit(event: string, args?: Array<any>): boolean

Parameters

  • event: string
  • args?: Array<any> optional

Returns

boolean

public listeners(event: string): Array<Function>

Parameters

  • event: string

Returns

Array<Function>

public on(event: string, listener: () => void): client

Parameters

  • event: string
  • listener: () => void

Returns

client

public on(event: "'connect'", cb: (connection: "websocket".connection) => void): client

Parameters

  • event: "'connect'"
  • cb: (connection: "websocket".connection) => void

Returns

client

public on(event: "'connectFailed'", cb: (err: Error) => void): client

Parameters

  • event: "'connectFailed'"
  • cb: (err: Error) => void

Returns

client

public once(event: string, listener: Function): EventEmitter

Parameters

  • event: string
  • listener: Function

Returns

EventEmitter

public removeAllListeners(event?: string): EventEmitter

Parameters

  • event?: string optional

Returns

EventEmitter

public removeListener(event: string, listener: Function): EventEmitter

Parameters

  • event: string
  • listener: Function

Returns

EventEmitter

public setMaxListeners(n: number)

Parameters

  • n: number