websocketplus

1.0.1 • Public • Published

Websocket Plus

A simple implementation of websocket auto-reconnection for ws

Installation

npm i websocketplus --save

Example

npm run example

Usage

const WebSocketPlus = require('websocketplus')
const webSocketPlus = new WebSocketPlus('wss://ws-feed.pro.coinbase.com', {
    openMessage: {
        type: "subscribe",
        product_ids: ["BTC-USD"],
        channels: ["level2"]
    }
})

webSocketPlus.on('open', () => {});

webSocketPlus.on('error', (message) => {
    console.log('error', message);
});

webSocketPlus.on('close', (message) => {
    console.log('close', message);
});

webSocketPlus.on('message', (message) => {
    console.log('message', message.type);
});

Package Sidebar

Install

npm i websocketplus

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

6.32 kB

Total Files

6

Last publish

Collaborators

  • ddkclaudio