Skip to content

small wrapper around websocket that does message buffering and reconnects

Notifications You must be signed in to change notification settings

ubergrape/websocket-buffering

 
 

Repository files navigation

WebSocket-Buffering

small wrapper around websocket that does message buffering and reconnects

Build Status Coverage Status Dependency Status

This is heavily inspired by stagas/websocket for the client side, but does the same wrapping for ws in node as well, to provide the same api.

Buffers messages and sends them once the connection has been established. Also offers a .connect() method to re-establish a broken connection.

Installation

$ npm install websocket-buffering
$ component install Swatinem/websocket-buffering

Usage

new WebSocketBuffering(url, [options])

Creates a new WebSocket connection to url. If options.connect is set to false, it will not automatically connect If options.buffering is set to false, it will throw when sending on a closed socket instead of buffering and sending once the socket is open.

ws.readyState

This is the readyState as defined by WebSocket. ws.OPEN and so on.

ws.send(data)

Send data down the wire, or buffer it to be sent once the connection is actually open.

ws.connect()

This opens up a new connection when it is not open yet. Does nothing otherwise.

Event: 'open'

Event: 'error' (err)

Event: 'message' (message)

Event: 'close'

License

LGPLv3

Released as free software as part of ChatGrape

About

small wrapper around websocket that does message buffering and reconnects

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 94.0%
  • Makefile 6.0%