Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Implements

  • WebSocket

Index

Constructors

constructor

  • new Shell(ws?: WebSocket): Shell

Properties

CLOSED

CLOSED: number = WebSocket.CLOSED

The connection is closed or couldn't be opened.

CLOSING

CLOSING: number = WebSocket.CLOSING

The connection is in the process of closing.

CONNECTING

CONNECTING: number = WebSocket.CONNECTING

The connection is not yet open.

OPEN

OPEN: number = WebSocket.OPEN

The connection is open and ready to communicate.

Protected _readyState

_readyState: number = WebSocket.CONNECTING

binaryType

binaryType: "blob" | "arraybuffer"

A string indicating the type of binary data being transmitted by the connection. This should be either "blob" if DOM Blob objects are being used or "arraybuffer" if ArrayBuffer objects are being used.

Protected closing

closing: boolean = false

Protected ws

ws: WebSocket

Accessors

bufferedAmount

bufferedAmount:

The number of bytes of data that have been queued using calls to send() but not yet transmitted to the network. This value resets to zero once all queued data has been sent. This value does not reset to zero when the connection is closed; if you keep calling send(), this will continue to climb. Read only

extensions

extensions:

The extensions selected by the server. This is currently only the empty string or a list of extensions as negotiated by the connection.

onclose

onclose:

An event listener to be called when the WebSocket connection's readyState changes to CLOSED. The listener receives a CloseEvent named "close".

onerror

onerror:

An event listener to be called when an error occurs. This is a simple event named "error".

onmessage

onmessage:

An event listener to be called when a message is received from the server. The listener receives a MessageEvent named "message".

onopen

onopen:

An event listener to be called when the WebSocket connection's readyState changes to OPEN; this indicates that the connection is ready to send and receive data. The event is a simple one with the name "open".

protocol

protocol:

readyState

readyState:

The current state of the connection; this is one of the Ready state constants. Read only.

url

url:

The URL as resolved by the constructor. This is always an absolute URL. Read only.

Methods

addEventListener

  • addEventListener<K>(type: K, listener: function, useCapture?: boolean): void
  • Register an event handler of a specific event type on the EventTarget.

    Type parameters

    • K: keyof WebSocketEventMap

    Parameters

    • type: K
    • listener: function
        • (this: WebSocket, ev: WebSocketEventMap[K]): any
        • Parameters

          • this: WebSocket
          • ev: WebSocketEventMap[K]

          Returns any

    • Optional useCapture: boolean

    Returns void

close

  • close(code?: number, reason?: string): void
  • Closes the WebSocket connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing.

    Parameters

    • Default value code: number = 1000
    • Optional reason: string

    Returns void

dispatchEvent

  • dispatchEvent(evt: Event): boolean
  • Dispatch an event to this EventTarget.

    Parameters

    • evt: Event

    Returns boolean

    The return value is false if event is cancelable and at least one of the event handlers which handled this event called Event.preventDefault(). Otherwise it returns true.

Protected forwardEvents

  • forwardEvents<K>(list?: K[]): void
  • Type parameters

    • K: keyof WebSocketEventMap

    Parameters

    • Optional list: K[]

    Returns void

Protected getReadyState

  • getReadyState(): number

removeEventListener

  • removeEventListener<K>(type: K, listener: function, useCapture?: boolean): void
  • Removes an event listener from the EventTarget.

    Type parameters

    • K: keyof WebSocketEventMap

    Parameters

    • type: K
    • listener: function
        • (this: WebSocket, ev: WebSocketEventMap[K]): any
        • Parameters

          • this: WebSocket
          • ev: WebSocketEventMap[K]

          Returns any

    • Optional useCapture: boolean

    Returns void

send

  • send(data: USVString | ArrayBuffer | Blob | ArrayBufferView): void
  • Enqueues the specified data to be transmitted to the server over the WebSocket connection, increasing the value of bufferedAmount by the number of bytes needed to contain the data. If the data can't be sent (for example, because it needs to be buffered but the buffer is full), t he socket is closed automatically.

    Parameters

    • data: USVString | ArrayBuffer | Blob | ArrayBufferView

      The data to send to the server. It may be one of the following types:

      • USVString A text string. The string is added to the buffer in UTF-8 format, and the value of bufferedAmount is increased by the number of bytes required to represent the UTF-8 string.
      • ArrayBuffer You can send the underlying binary data used by a typed array object; its binary data contents are queued in the buffer, increasing the value of bufferedAmount by the requisite number of bytes.
      • Blob Specifying a Blob enqueues the blob's raw data to be transmitted in a binary frame. The value of bufferedAmount is increased by the byte size of that raw data.
      • ArrayBufferView You can send any JavaScript typed array object as a binary frame; its binary data contents are queued in the buffer, increasing the value of bufferedAmount by the requisite number of bytes.

    Returns void

Protected stopForwardingEvents

  • stopForwardingEvents(): void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc