websocket-reconnector
A wrapper to W3C WebSocket objects to seamlesly add reconnection feature.
Installation
$ npm install --save websocket-reconnector
Usage
const WebSocketReconnector = // Wrap any W3C WebSocket implementationconst ReconnectingWebSocket = // Create your WebSocket client as usual and attach eventsconst client = // On connection and one every reconnection, send a messageclient // A response is always received, no need to resubscribe to eventsclient
API
The API is fully compatible with the W3C WebSocket API.
In addition, the following additional method is available:
client.reconnect()
Closes the underlying websocket instance and initiates a new connection.
License
MIT