1.0.1 • Published 3 years ago

@xroom.app/reconnecting-socket v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Wrapper reconnects ws socket after break

Installation

Run from command line

npm i @xroom.app/reconnecting-socket

Usage example

const { getReconnectingSocket } = require('@xroom.app/reconnecting-socket')

const url = 'http://foobar.com'

const getSocket = getReconnectingSocket(url, 1000)

let clientId

getSocket().on('open', () => {
    getSocket().send('requestId')
})

getSocket().on('message', (message) => {
    clientId = message.toString()
})