WebSocket

open external class WebSocket : WebSocket(source)

Constructors

Link copied to clipboard
constructor(url: String)
constructor(url: String, protocols: String = definedExternally)

WebSocket

constructor(url: String, protocols: ReadonlyArray<String> = definedExternally)

WebSocket

constructor(url: String, protocols: WebSocketOptions = definedExternally)

WebSocket

Properties

Link copied to clipboard

A string controlling how incoming binary messages are exposed on the message event. Can be nodebuffer, arraybuffer, or blob. The default is nodebuffer.

Link copied to clipboard
external val bufferedAmount: Double

An Integer representing the number of bytes of application data that have been queued via send() but not yet handed off to the network.

Link copied to clipboard
external val extensions: String

A string containing the extensions negotiated by the server (for example permessage-deflate).

Link copied to clipboard
external var onclose: Function<*>?

A Function | null event handler for the close event. Equivalent to calling addEventListener('close', ...).

Link copied to clipboard
external var onerror: Function<*>?

A Function | null event handler for the error event. Equivalent to calling addEventListener('error', ...).

Link copied to clipboard
external var onmessage: Function<*>?

A Function | null event handler for the message event. Equivalent to calling addEventListener('message', ...).

Link copied to clipboard
external var onopen: Function<*>?

A Function | null event handler for the open event. Equivalent to calling addEventListener('open', ...).

Link copied to clipboard
external val protocol: String

A string containing the subprotocol selected by the server. The empty string until the connection is open or if the server did not select a subprotocol.

Link copied to clipboard
external val readyState: Double

An Integer representing the current state of the connection: one of WebSocket.CONNECTING (0), WebSocket.OPEN (1), WebSocket.CLOSING (2), or WebSocket.CLOSED (3).

Link copied to clipboard
external val url: String

A string representing the resolved URL of the connection.

Functions

Link copied to clipboard
external fun close(code: Double = definedExternally, reason: String = definedExternally)

Closes the connection. Calling close() while still CONNECTING aborts the handshake.

Link copied to clipboard
open external override fun dispatchEvent(event: Event): Boolean
Link copied to clipboard
external fun send(data: ArrayBufferLike)
external fun send(data: ArrayBufferView<*>)
external fun send(data: String)
external fun send(data: Blob)

Enqueues data to be transmitted to the server. Throws an InvalidStateError DOMException if readyState is CONNECTING.

Link copied to clipboard
open external fun <T : Event> when(type: EventType<T>, options: ObservableEventListenerOptions?): Observable<T>