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

This branch is 1 commit ahead of master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

4d9c3ed · Feb 11, 2022

History

35 Commits
Nov 19, 2020
Mar 30, 2019
Mar 26, 2019
Mar 25, 2019
Mar 25, 2019
Apr 14, 2019
Feb 11, 2022
Jul 7, 2019
Mar 25, 2019
Apr 6, 2019
Apr 6, 2019

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