Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/marchaos/resilient-websocket

A client WebSocket wrapper with support for reconnection and ping/pong with a familiar API. Written in TypeScript.
https://github.com/marchaos/resilient-websocket

ping-pong reconnect reconnecting-websocket resilient websocket

Last synced: 11 days ago
JSON representation

A client WebSocket wrapper with support for reconnection and ping/pong with a familiar API. Written in TypeScript.

Awesome Lists containing this project

README

        

# resilient-websocket
A client WebSocket wrapper with support for reconnection and ping/pong with a familiar API. Written in TypeScript

# Installing

```sh
npm install resilient-websocket --save
```

# API

```js
import ResilientWebSocket, { WebSocketEvent } from 'resilient-websocket';

const opts = {
autoJsonify: true, // parse json message from server, stringify messages on send,
pingEnabled: true // send ping / pong messages
};

const rSock = new ResilientWebSocket(url, opts);

rSock.on(WebSocketEvent.CONNECTION, () => {
rSock.on(WebSocketEvent.MESSAGE, (message) => {
console.info('received message from the server', message);
rSock.send({ message: 'Right back at ya, buddy!' });
});
});
```