Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Connection<T>

Type parameters

Hierarchy

  • Connection

Index

Constructors

Properties

#backoff: Backoff = ...

The back-off queue.

#close: (code: number, reason: string) => void

Type declaration

    • (code: number, reason: string): void
    • The bound callback function for onClose.

      Parameters

      • code: number
      • reason: string

      Returns void

#error: (err: Error) => void

Type declaration

    • (err: Error): void
    • The bound callback function for onError.

      Parameters

      • err: Error

      Returns void

#message: (d: Data) => void

Type declaration

    • (d: Data): void
    • The bound callback function for onMessage.

      Parameters

      • d: Data

      Returns void

#open: () => void

Type declaration

    • (): void
    • The bound callback function for onOpen.

      Returns void

#queue: Sendable[] = []

The queue of requests to be processed.

#send: (__namedParameters: Sendable) => void

Type declaration

    • (__namedParameters: Sendable): void
    • The bound callback function for wsSend.

      Parameters

      • __namedParameters: Sendable

      Returns void

#upgrade: (req: IncomingMessage) => void

Type declaration

    • (req: IncomingMessage): void
    • The bound callback function for onUpgrade.

      Parameters

      • req: IncomingMessage

      Returns void

node: T

The node that owns this connection.

options: Options

The websocket options.

resumeKey?: null | string

The resume key, check Options.resumeKey for more information.

url: string

The url the connection connects to.

ws: null | WebSocket

The websocket connection.

Methods

  • _connect(): Promise<void>
  • _flush(): Promise<void>
  • _reconnect(): void
  • _registerWSEventListeners(): void
  • close(code?: number, data?: string): Promise<boolean>
  • Closes the WebSocket connection.

    Parameters

    • Optional code: number

      The close code.

    • Optional data: string

      The data to be sent.

    Returns Promise<boolean>

  • configureResuming(timeout?: number, key?: null | string): Promise<void>
  • Configures the resuming for this connection.

    Parameters

    • timeout: number = 60

      The number of seconds after disconnecting before the session is closed anyways. This is useful for avoiding accidental leaks.

    • key: null | string = null

      The key to send when resuming the session. Set to null or leave unset to disable resuming.

    Returns Promise<void>

  • connect(): Promise<void>
  • onClose(code: number, reason: string): void
  • onError(err: Error): void
  • onMessage(d: Data): void
  • onOpen(): void
  • onUpgrade(req: IncomingMessage): void
  • wsSend(__namedParameters: Sendable): void

Generated using TypeDoc