An open API service indexing awesome lists of open source software.

https://github.com/gamestdio/websocket

WebSocket client with reconnect back-off feature. Works in the browser, Node.js and React Native.
https://github.com/gamestdio/websocket

react-native websockets

Last synced: 11 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# @gamestdio/websocket

WebSocket with reconnect back-off feature.

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

## Installation

`npm i @gamestdio/websocket`

## Usage

`WebSocketClient` behaves exactly in the same way as `WebSocket`.

It accepts an optional third parameter, which is used to configure
[backoff](https://github.com/MathieuTurcotte/node-backoff) feature.

```javascript
// fibonacci backoff strategy
var conn = new WebSocketClient('ws://' + host + ':8080', [], {
backoff: "fibonacci"
});
```

```javascript
// exponential backoff strategy
var conn = new WebSocketClient('ws://' + host + ':8080', [], {
backoff: "exponential"
});
```

## Event Listeners

- onclose
- onerror
- onmessage
- onopen
- onreconnect

## License

MIT