Skip to content

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

License

Notifications You must be signed in to change notification settings

marchaos/resilient-websocket

Repository files navigation

resilient-websocket

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

Installing

npm install resilient-websocket --save

API

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!' });
    });
});

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •