WebSocket with reconnect back-off feature.
For Node.js support, you should install the ws module in your project.
npm i @gamestdio/websocket
WebSocketClient behaves exactly in the same way as WebSocket.
It accepts an optional third parameter, which is used to configure backoff feature.
// fibonacci backoff strategy
var conn = new WebSocketClient('ws://' + host + ':8080', [], {
backoff: "fibonacci"
});// exponential backoff strategy
var conn = new WebSocketClient('ws://' + host + ':8080', [], {
backoff: "exponential"
});- onclose
- onerror
- onmessage
- onopen
- onreconnect
MIT