WS

Hierarchy

  • TypedEventTarget
    • WS

Constructors

Properties

onclose: undefined | (this: WS, ev: CloseEvent) => any = undefined
onerror: undefined | (this: WS, ev: Event) => any = undefined
onmessage: undefined | (this: WS, ev: MessageEvent) => any = undefined
onopen: undefined | (this: WS, ev: Event) => any = undefined
options: Required<WSOptions>

Accessors

  • get bufferedAmount(): number

    Returns the number of bytes of application data (UTF-8 text and binary data) that have been queued using send() but not yet been transmitted to the network.

    If the WebSocket connection is closed, this attribute's value will only increase with each call to the send() method. (The number does not reset to zero once the connection closes.)

    MDN Reference

    Returns number

  • get protocol(): string

    Returns the subprotocol selected by the server, if any. It can be used in conjunction with the array form of the constructor's second argument to perform subprotocol negotiation.

    MDN Reference

    Returns string

Methods

  • Closes the WebSocket connection, optionally using code as the the WebSocket connection close code and reason as the the WebSocket connection close reason.

    MDN Reference

    Parameters

    • Optionalcode: number = 1000
    • Optionalreason: string

    Returns void