Skip to content

1681-engine / index / ConnectionOptions

Interface: ConnectionOptions ​

Defined in: src/net/Connection.ts:22

Properties ​

fatalCloseCodes? ​

ts
optional fatalCloseCodes?: readonly number[];

Defined in: src/net/Connection.ts:36

Close codes after which it must not reconnect (default none): the server's "kicked", "banned", "update required"… The close event then says willRetry: false.


hello? ​

ts
optional hello?: () => unknown;

Defined in: src/net/Connection.ts:29

Sent on every (re)connect as hello.data.

Returns ​

unknown


maxBackoffMs? ​

ts
optional maxBackoffMs?: number;

Defined in: src/net/Connection.ts:25


onResume? ​

ts
optional onResume?: (cb) => () => void;

Defined in: src/net/Connection.ts:44

How the probe hears of a resume (default onAppResume); returns the unsubscribe.

Parameters ​

ParameterType
cb() => void

Returns ​

() => void


pingMs? ​

ts
optional pingMs?: number;

Defined in: src/net/Connection.ts:27

Ping interval for the server clock and the round-trip time (default 1000 ms).


reconnect? ​

ts
optional reconnect?: boolean;

Defined in: src/net/Connection.ts:24

Reconnect after the socket drops (default true), waiting longer each time up to maxBackoffMs.


resumeProbeMs? ​

ts
optional resumeProbeMs?: number;

Defined in: src/net/Connection.ts:42

After the app returns from the background, ping and give the server this long to answer (default 0: off). A phone that froze the tab can come back to a socket that still says it is open and is dead; with no pong in time the socket is dropped (close code CLOSE_NO_ANSWER) and reconnected as after any drop.


WebSocket? ​

ts
optional WebSocket?: (url, protocols?) => WebSocket;

Defined in: src/net/Connection.ts:31

The WebSocket class (default the global one; Node 22+ and browsers have it).

Parameters ​

ParameterType
urlstring | URL
protocols?string | string[]

Returns ​

WebSocket

Released under the MIT License.