@gamestdio/websocket

WebSocket browser client with reconnect back-off feature.

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
590Jul 15, 2019Nov 18, 2015Minified + gzip package size for @gamestdio/websocket in KB

Readme

@gamestdio/websocket

WebSocket with reconnect back-off feature.

For Node.js support, you should install the ws module in your project.

Usage

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', null, {
  backoff: "fibonacci"
});
// exponential backoff strategy
var conn = new WebSocketClient('ws://' + host + ':8080', null, {
  backoff: "exponential"
});

Event Listeners

  • onclose
  • onerror
  • onmessage
  • onopen
  • onreconnect

License

MIT

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.