Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

Properties

CLOSED: 3

The connection is closed.

CLOSING: 2

The connection is in the process of closing.

CONNECTING: 0

The connection is not yet open.

OPEN: 1

The connection is open and ready to communicate.

binaryType: "nodebuffer" | "arraybuffer" | "fragments"
bufferedAmount: number
extensions: string
isPaused: boolean

Indicates whether the websocket is paused

protocol: string
readyState: 0 | 1 | 2 | 3

The current state of the connection

url: string
CLOSED: 3

The connection is closed.

CLOSING: 2

The connection is in the process of closing.

CONNECTING: 0

The connection is not yet open.

OPEN: 1

The connection is open and ready to communicate.

Methods

  • Parameters

    • event: "close"
    • listener: (code: number, reason: Buffer) => void
        • (code: number, reason: Buffer): void
        • Parameters

          • code: number
          • reason: Buffer

          Returns void

    Returns WebSocket

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns WebSocket

  • Parameters

    • event: "upgrade"
    • listener: (request: IncomingMessage) => void
        • (request: IncomingMessage): void
        • Parameters

          • request: IncomingMessage

          Returns void

    Returns WebSocket

  • Parameters

    Returns WebSocket

  • Parameters

    • event: "open"
    • listener: () => void
        • (): void
        • Returns void

    Returns WebSocket

  • Parameters

    • event: "ping" | "pong"
    • listener: (data: Buffer) => void
        • (data: Buffer): void
        • Parameters

          • data: Buffer

          Returns void

    Returns WebSocket

  • Parameters

    • event: "unexpected-response"
    • listener: (request: ClientRequest, response: IncomingMessage) => void
        • (request: ClientRequest, response: IncomingMessage): void
        • Parameters

          • request: ClientRequest
          • response: IncomingMessage

          Returns void

    Returns WebSocket

  • Parameters

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

          • Rest ...args: any[]

          Returns void

    Returns WebSocket

  • close(code?: number, data?: string | Buffer): void
  • Parameters

    • Optional code: number
    • Optional data: string | Buffer

    Returns void

  • pause(): void
  • Pause the websocket causing it to stop emitting events. Some events can still be emitted after this is called, until all buffered data is consumed. This method is a noop if the ready state is CONNECTING or CLOSED.

    Returns void

  • ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void
  • Parameters

    • Optional data: any
    • Optional mask: boolean
    • Optional cb: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns void

  • pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void
  • Parameters

    • Optional data: any
    • Optional mask: boolean
    • Optional cb: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns void

  • Parameters

    • event: "close"
    • listener: (code: number, reason: Buffer) => void
        • (code: number, reason: Buffer): void
        • Parameters

          • code: number
          • reason: Buffer

          Returns void

    Returns WebSocket

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns WebSocket

  • Parameters

    • event: "upgrade"
    • listener: (request: IncomingMessage) => void
        • (request: IncomingMessage): void
        • Parameters

          • request: IncomingMessage

          Returns void

    Returns WebSocket

  • Parameters

    Returns WebSocket

  • Parameters

    • event: "open"
    • listener: () => void
        • (): void
        • Returns void

    Returns WebSocket

  • Parameters

    • event: "ping" | "pong"
    • listener: (data: Buffer) => void
        • (data: Buffer): void
        • Parameters

          • data: Buffer

          Returns void

    Returns WebSocket

  • Parameters

    • event: "unexpected-response"
    • listener: (request: ClientRequest, response: IncomingMessage) => void
        • (request: ClientRequest, response: IncomingMessage): void
        • Parameters

          • request: ClientRequest
          • response: IncomingMessage

          Returns void

    Returns WebSocket

  • Parameters

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

          • Rest ...args: any[]

          Returns void

    Returns WebSocket

  • resume(): void
  • Make a paused socket resume emitting events. This method is a noop if the ready state is CONNECTING or CLOSED.

    Returns void

  • send(data: any, cb?: (err?: Error) => void): void
  • send(data: any, options: { binary?: boolean; compress?: boolean; fin?: boolean; mask?: boolean }, cb?: (err?: Error) => void): void
  • Parameters

    • data: any
    • Optional cb: (err?: Error) => void
        • (err?: Error): void
        • Parameters

          • Optional err: Error

          Returns void

    Returns void

  • Parameters

    • data: any
    • options: { binary?: boolean; compress?: boolean; fin?: boolean; mask?: boolean }
      • Optional binary?: boolean
      • Optional compress?: boolean
      • Optional fin?: boolean
      • Optional mask?: boolean
    • Optional cb: (err?: Error) => void
        • (err?: Error): void
        • Parameters

          • Optional err: Error

          Returns void

    Returns void

  • terminate(): void
  • Returns void