Skip to content

Interface: WebSocket ​

Defined in: types/desktop-engine.d.ts:5552

A WebSocket connection

Extends ​

Properties ​

binaryType ​

ts
binaryType: "blob" | "arraybuffer";

Defined in: types/desktop-engine.d.ts:5563

What binary messages are: "blob" (the default, like browsers) or "arraybuffer"; other values are ignored


bufferedAmount ​

ts
readonly bufferedAmount: number;

Defined in: types/desktop-engine.d.ts:5561

Bytes passed to send() that haven't been sent yet


CLOSED ​

ts
readonly CLOSED: 3;

Defined in: types/desktop-engine.d.ts:5575


CLOSING ​

ts
readonly CLOSING: 2;

Defined in: types/desktop-engine.d.ts:5574


CONNECTING ​

ts
readonly CONNECTING: 0;

Defined in: types/desktop-engine.d.ts:5572


extensions ​

ts
readonly extensions: string;

Defined in: types/desktop-engine.d.ts:5559


onclose ​

ts
onclose: ((this, event) => void) | null;

Defined in: types/desktop-engine.d.ts:5567


onerror ​

ts
onerror: ((this, event) => void) | null;

Defined in: types/desktop-engine.d.ts:5566


onmessage ​

ts
onmessage: ((this, event) => void) | null;

Defined in: types/desktop-engine.d.ts:5565


onopen ​

ts
onopen: ((this, event) => void) | null;

Defined in: types/desktop-engine.d.ts:5564


OPEN ​

ts
readonly OPEN: 1;

Defined in: types/desktop-engine.d.ts:5573


protocol ​

ts
readonly protocol: string;

Defined in: types/desktop-engine.d.ts:5558

The subprotocol the server picked


readyState ​

ts
readonly readyState: 0 | 1 | 2 | 3;

Defined in: types/desktop-engine.d.ts:5556

WebSocket.CONNECTING, OPEN, CLOSING or CLOSED


url ​

ts
readonly url: string;

Defined in: types/desktop-engine.d.ts:5554

The URL, with http(s) turned into ws(s)

Methods ​

addEventListener() ​

ts
addEventListener<K>(
   type, 
   listener, 
   options?
): void;

Defined in: types/desktop-engine.d.ts:4865

Type Parameters ​

Type Parameter
K extends keyof WebSocketEventMap

Parameters ​

ParameterType
typeK
listener(this, event) => void
options?AddEventListenerOptions

Returns ​

void

Inherited from ​

EventTarget.addEventListener


close() ​

ts
close(code?, reason?): void;

Defined in: types/desktop-engine.d.ts:5571

code is 1000 (the default) or 3000-4999, reason at most 123 bytes of UTF-8

Parameters ​

ParameterType
code?number
reason?string

Returns ​

void


dispatchEvent() ​

ts
dispatchEvent(event): boolean;

Defined in: types/desktop-engine.d.ts:4868

Returns false when a listener called preventDefault() on a cancelable event

Parameters ​

ParameterType
eventEvent

Returns ​

boolean

Inherited from ​

EventTarget.dispatchEvent


removeEventListener() ​

ts
removeEventListener<K>(type, listener): void;

Defined in: types/desktop-engine.d.ts:4866

Type Parameters ​

Type Parameter
K extends keyof WebSocketEventMap

Parameters ​

ParameterType
typeK
listener(this, event) => void

Returns ​

void

Inherited from ​

EventTarget.removeEventListener


send() ​

ts
send(data): void;

Defined in: types/desktop-engine.d.ts:5569

Sends a text or binary message; throws an "InvalidStateError" DOMException while connecting, dropped once closing

Parameters ​

ParameterType
data| string | ArrayBuffer | ArrayBufferView<ArrayBufferLike> | Blob

Returns ​

void

The SDK is released under the Apache License 2.0