Skip to content

WebSocket client with reconnect back-off feature. Works in the browser, Node.js and React Native.

License

Notifications You must be signed in to change notification settings

hamidjafari/websocket

 
 

Repository files navigation

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

Event Listeners

  • onclose
  • onerror
  • onmessage
  • onopen
  • onreconnect

License

MIT

About

WebSocket client with reconnect back-off feature. Works in the browser, Node.js and React Native.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 84.9%
  • HTML 11.4%
  • TypeScript 3.7%