{"name":"reconnect","version":"0.0.2","homepage":"https://github.com/dominictarr/reconnect","repository":{"type":"git","url":"git://github.com/dominictarr/reconnect.git"},"dependencies":{"backoff":"~0.3.0","shoe":"0.0.4"},"devDependencies":{"tap":"0.3.0","macgyver":"1.7.0"},"browserify":"./shoe","scripts":{"test":"tap test"},"author":{"name":"'Dominic Tarr'","email":"dominic.tarr@gmail.com","url":"http://dominictarr.com"},"license":"MIT","_id":"reconnect@0.0.2","description":"reconnect to a network stream, (currently supports [tcp](http://nodejs.org/api/net.html),  and [shoe](https://github.com/substack/shoe) on the client-side.","dist":{"shasum":"86e60c60543b3e6a7a891a2d518ecc5e141180b5","tarball":"http://registry-npm.ywwl.com/reconnect/download/reconnect-0.0.2.tgz","integrity":"sha512-igWBT8zVppay8LS201GmvyvUt32WrhRrA+pvytl4OHAOEuI5Y2LLChec0hClgeqcDb1nd6CIJqBr7xU6pWNWUw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCG3AvWmCXEfUWOqx9WXtgIE5NFQ5kWDcuypGJMuZH6DAIhAOYhMC8QxCkf4xR4ZjbP1w3WNNsOTS1M/SbRt1qpLDtz"}],"size":41772,"noattachment":false,"key":"/reconnect/-/reconnect-0.0.2.tgz"},"maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}],"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":1345066466589,"_cnpm_publish_time":1345066466589,"dist-tags":{"latest":"2.0.2"}}