{"name":"reconnect","version":"2.0.1","homepage":"https://github.com/dominictarr/reconnect","repository":{"type":"git","url":"git://github.com/dominictarr/reconnect.git"},"dependencies":{"request":">=2.12 <3","engine.io-stream":"~0.4.2","reconnect-core":"0.0.1","shoe":">=0.0.7 <1","sockjs-stream":">=1 <2"},"optionalDependencies":{"shoe":">=0.0.7 <1","sockjs-stream":">=1 <2"},"devDependencies":{"tap":"~0.4.2","macgyver":"1.7.0"},"browser":{"./index.js":"./shoe-client.js","./shoe.js":"./shoe-client.js"},"scripts":{"test":"tap test/"},"author":{"name":"'Dominic Tarr'","email":"dominic.tarr@gmail.com","url":"http://dominictarr.com"},"license":"MIT","description":"Reconnect a stream (tcp, ws, tls, http) when network goes down.","bugs":{"url":"https://github.com/dominictarr/reconnect/issues"},"_id":"reconnect@2.0.1","_shasum":"ad63a3179d2454fda725bba85f735457f0724a46","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"dominictarr","email":"dominic.tarr@gmail.com"},"maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}],"dist":{"shasum":"ad63a3179d2454fda725bba85f735457f0724a46","tarball":"http://registry-npm.ywwl.com/reconnect/download/reconnect-2.0.1.tgz","integrity":"sha512-1lBX7TEnIrE9jeas1fBnqv0OJtZ4Ddfj41SP4RqGixzLf+qkVZ7N/bveE+98bu7oRAXO7GGg7ry9HqdMMvBOBA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCR32SUazTpiyeMw6AKKQkI+z4ie4oIiftGXrsCgBvQLQIhANBMJtITryG3WyYL5J0JHpf6bazKH4IAka5WpuokcKXy"}],"size":4206,"noattachment":false,"key":"/reconnect/-/reconnect-2.0.1.tgz"},"directories":{},"readme":"# reconnect\n\nReconnect a stream (tcp, ws, tls, http) when network goes down.\n\n## Status: LEGACY, use [reconnect-core](https://github.com/juliangruber/reconnect-core)\n\nThis module should now be considered legacy,\nit is recommend to use reconnect-core directly.\nThis module is now only a bundle of wrappers around reconnect-core.\n\nCurrently supports:\n* [tcp](http://nodejs.org/api/net.html)\n* [shoe](https://github.com/substack/shoe) (websocket fallback - on the client-side)\n* [tls](http://nodejs.org/api/tls.html)\n* [sockjs-stream](https://github.com/Raynos/sockjs-stream) (server side websockets)\n* [engine.io-stream](https://github.com/Raynos/engine.io-stream)\n\n## Example\n\nPass a function that will be called every time the stream connects.\nif the connection is broken, reconnect will make a new connection\nand call this function again.\n``` js\nvar reconnect = require('reconnect')\n\nreconnect(function (stream) {\n  //called every time the connection is remade.\n  //only one connection will ever be live at one time.\n}).connect(port)\n```\n\n## WebSockets\n\nwebsockets can be used from both the client and the server, with the same code!\n\n``` js\nvar reconnect = require('reconnect/shoe')\n\nreconnect(function (stream) {\n  //called every time the connection is remade.\n  //only one connection will ever be live at one time.\n}).connect('http://localhost:8080/ws')\n```\n\na [shoe](http://npm.im/shoe) server must be used.\n\n## API\n\n### reconnect (opts, onConnect)\n\nif `opts` is an object it will be passed to [backoff](https://github.com/MathieuTurcotte/node-backoff)\nwhich handles throttling the reconnection attempts. it also accepts a `type` parameter, which may\nbe either `'fibonacci'` or `'exponential'`.\n\n``` js\n//example opts\nvar opts = {\n  randomisationFactor: 0,\n  initialDelay: 10,\n  maxDelay: 300\n}\n```\n\n`opts` is optional. If `opts.immediate` is `true` then we will treat the\nstream as if it does not emit a `\"connect\"` event and fall back to listening\nto the first piece of data. This is useful for non connection streams like\ndatabase cursors or tailing files.\n\npassing `onConnect` to reconnect is short hand for `reconnect(opts).on('connect', onConnect)`\n\n### reconnect.connect (...)\n\nattempt to connect. the arguments will be passed onto the underlying stream type.\n(either you are calling `shoe(uri)` or `net.connect(port)`)\nthese arguments will be used for every subsequent connection attempt.\n\n### emit('connect', stream)\n\nemitted when a new connection is made (that includes after a disconnection!)\n\n### emit('disconnect', stream)\n\nemitted when the stream has disconnected.\n\n### emit ('backoff', attempts, delay)\n\nreemitted from [backoff](https://github.com/MathieuTurcotte/node-backoff)\nwhen reconnect is waiting for the next time to connect.\n\n### emit ('reconnect', attempts, delay)\n\nemitted when attempting a new connection.\n\n### reconnector.reconnect\n\nset to `false` and `reconnect` will not automatically reconnect.\nstarts out true.\n\n## Extending\n\nUse [reconnect-core](https://github.com/juliangruber/reconnect-core) instead.\n\n## Widget\n\nThe reconnect widget has been moved into a separate module\n[reconnect-widget](https://github.com/dominictarr/reconnect-widget)\n\n## License\n\nMIT\n","publish_time":1404254556549,"_cnpm_publish_time":1404254556549,"dist-tags":{"latest":"2.0.2"}}