0.1.12 • Published 7 years ago

websocket.js v0.1.12

Weekly downloads
121
License
-
Repository
github
Last release
7 years ago

websocket.js

WebSocket browser client with reconnect back-off feature.

Usage

WebSocketClient behaves exactly in the same way as WebSocket.

It accepts an optional third parameter, which is used to configure backoff feature.

// fibonacci backoff strategy
var conn = new WebSocketClient('ws://' + host + ':8080', null, {
  strategy: "fibonacci",
  randomisationFactor: 0, // defaults to 0, must be between 0 and 1
  initialDelay: 10,       // defaults to 100 ms
  maxDelay: 300           // defaults to 10000 ms
});
// exponential backoff strategy
var conn = new WebSocketClient('ws://' + host + ':8080', null, {
  strategy: "exponential",
  randomisationFactor: 0, // defaults to 0, must be between 0 and 1
  initialDelay: 10,       // defaults to 100 ms
  maxDelay: 300,          // defaults to 10000 ms
  factor: 3               // defaults to 2, must be greater than 1
});

Event Listeners

  • onclose
  • onerror
  • onmessage
  • onopen
  • onreconnect

License

MIT

0.1.12

7 years ago

0.1.11

7 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago