Skip to content

Interface: WebSocket ​

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

A WebSocket connection

Extends ​

Properties ​

binaryType ​

ts
binaryType: "blob" | "arraybuffer";

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

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:4125

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


CLOSED ​

ts
readonly CLOSED: 3;

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


CLOSING ​

ts
readonly CLOSING: 2;

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


CONNECTING ​

ts
readonly CONNECTING: 0;

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


extensions ​

ts
readonly extensions: string;

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


onclose ​

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

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


onerror ​

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

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


onmessage ​

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

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


onopen ​

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

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


OPEN ​

ts
readonly OPEN: 1;

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


protocol ​

ts
readonly protocol: string;

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

The subprotocol the server picked


readyState ​

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

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

WebSocket.CONNECTING, OPEN, CLOSING or CLOSED


url ​

ts
readonly url: string;

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

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:3810

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:4135

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:3813

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:3811

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:4133

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