Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

54 lines (34 sloc) 1.447 kB

engine.io client reconnect

NPM version

Reconnect wrapper for engine.io-client - inspired by https://github.com/cayasso/engine.io-reconnect

Install

npm install eio-reconnect

Use

client = require 'engine.io-client'
reconnect = require 'eio-reconnect'

# Define any options
options = 
  reconnectTimeout: 30 * 1000

# Add reconnect functionality to eio
eio = reconnect client('ws://localhost:8080'), options

eio.on 'reconnect', (attempts) -> console.log 'Reconnected after %d attempts', attempts

eio.on 'reconnecting', (attempts) -> console.log 'Reconnect attempt %d', attempts

eio.on 'reconnect_timeout', (time) -> console.log 'Timeout after %dms', time

eio.on 'reconnect_error', (error) -> console.log 'Error while reconnecting', error

Options (defaults)

  • allowedReconnectionAttempts (Infinity) - total number of reconnect attempts allowed
  • reconnectDelay (1000) - the time between reconnect attempts (used as a multiplier - attempt * reconnectDelay)
  • reconnectTimeout (60 * 1000) - the maximum time to attempt to reconnect

Testing

grunt test

Contributing

  1. Create your feature branch (git checkout -b my-new-feature)
  2. Commit your changes (git commit -am 'Added some feature')
  3. Push to the branch (git push origin my-new-feature)
  4. Create new Pull Requests
Jump to Line
Something went wrong with that request. Please try again.