{"_id":"@druide/reconnecting-websocket","_rev":"3-3541e83cc04e13842bfd67a566c502fd","name":"@druide/reconnecting-websocket","dist-tags":{"latest":"1.2.0"},"versions":{"1.1.0":{"name":"@druide/reconnecting-websocket","version":"1.1.0","description":"A small JavaScript library that decorates the WebSocket API to provide a WebSocket connection that will automatically reconnect if the connection is dropped.","main":"reconnecting-websocket.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/druide/reconnecting-websocket.git"},"author":{"name":"Joe Walnes"},"license":"MIT","homepage":"https://github.com/druide/reconnecting-websocket","gitHead":"76be350055332e5ff9e04559c3e762f9523dd7a0","bugs":{"url":"https://github.com/druide/reconnecting-websocket/issues"},"_id":"@druide/reconnecting-websocket@1.1.0","_npmVersion":"5.5.1","_nodeVersion":"8.7.0","_npmUser":{"name":"druide","email":"ingvuil@gmail.com"},"dist":{"integrity":"sha512-eLW78aNCvlIpFrJ+Z6JxrvGj75pGtSUZ6r7fOawFHb+mw6tUgXryTjd8UG1P12il9+iW0qJZAJWm80uw5CtZfg==","shasum":"052c2d7d9a73ac1264992b85ea196dacddbf50cd","tarball":"https://registry.npmjs.org/@druide/reconnecting-websocket/-/reconnecting-websocket-1.1.0.tgz","fileCount":5,"unpackedSize":21116,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCxsdWQvmcdgBLuQs9Ru4nY8TYdhU9pLtIieitFHa39VQIgQbpSp8QkDxedhwALNDDymnJARgHEzxANsYxR2d0s4ww="}]},"maintainers":[{"name":"druide","email":"ingvuil@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/reconnecting-websocket_1.1.0_1518611645901_0.9693776091941759"},"_hasShrinkwrap":false},"1.2.0":{"name":"@druide/reconnecting-websocket","version":"1.2.0","description":"A small JavaScript library that decorates the WebSocket API to provide a WebSocket connection that will automatically reconnect if the connection is dropped.","main":"reconnecting-websocket.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/druide/reconnecting-websocket.git"},"author":{"name":"Joe Walnes"},"license":"MIT","homepage":"https://github.com/druide/reconnecting-websocket","gitHead":"d788248185088998eaf5c7429c78c71ca4d8bcb1","bugs":{"url":"https://github.com/druide/reconnecting-websocket/issues"},"_id":"@druide/reconnecting-websocket@1.2.0","_npmVersion":"5.5.1","_nodeVersion":"8.7.0","_npmUser":{"name":"druide","email":"ingvuil@gmail.com"},"dist":{"integrity":"sha512-s3fa1VV5MX/0rAsa+66N18wldYqKtcJq6PLEvNhO24SbFeM4UuQYLdze4OixL6FQyxEIcCB+VzkGt02EgIEj9w==","shasum":"25d376fde9ea69da05087a4e9a7e9c667bf1de5e","tarball":"https://registry.npmjs.org/@druide/reconnecting-websocket/-/reconnecting-websocket-1.2.0.tgz","fileCount":5,"unpackedSize":21305,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFDyBhvcvUSFAOi4EqgyvcXHJSV087B7II6kWiKgQPD9AiA2hBlxi5efKAv/8lTPI9EcQ6Y+kwEa4y82pQhT6W7MAA=="}]},"maintainers":[{"name":"druide","email":"ingvuil@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/reconnecting-websocket_1.2.0_1519389340813_0.9589534506617732"},"_hasShrinkwrap":false}},"time":{"created":"2018-02-14T12:34:05.592Z","1.1.0":"2018-02-14T12:34:06.585Z","modified":"2022-04-05T05:42:43.981Z","1.2.0":"2018-02-23T12:35:40.860Z"},"maintainers":[{"name":"druide","email":"ingvuil@gmail.com"}],"description":"A small JavaScript library that decorates the WebSocket API to provide a WebSocket connection that will automatically reconnect if the connection is dropped.","homepage":"https://github.com/druide/reconnecting-websocket","repository":{"type":"git","url":"git://github.com/druide/reconnecting-websocket.git"},"author":{"name":"Joe Walnes"},"bugs":{"url":"https://github.com/druide/reconnecting-websocket/issues"},"license":"MIT","readme":"ReconnectingWebSocket\n=====================\n\nA small JavaScript library that decorates the WebSocket API to provide a WebSocket connection that will automatically reconnect if the connection is dropped.\n\nIt is API compatible, so when you have:\n\n```javascript\nvar ws = new WebSocket('ws://....');\n```\n\nyou can replace with:\n\n```javascript\nvar ws = new ReconnectingWebSocket('ws://....');\n```\n\nMinified library with gzip compression is less than 600 bytes.\n\nHow reconnections occur\n-----------------------\n\nWith the standard `WebSocket` API, the events you receive from the WebSocket instance are typically:\n\n    onopen\n    onmessage\n    onmessage\n    onmessage\n    onclose // At this point the WebSocket instance is dead.\n\nWith a `ReconnectingWebSocket`, after an `onclose` event is called it will automatically attempt to reconnect. In addition, a connection is attempted repeatedly (with a small pause) until it succeeds. So the events you receive may look something more like:\n\n    onopen\n    onmessage\n    onmessage\n    onmessage\n    onclose\n    // ReconnectingWebSocket attempts to reconnect\n    onopen\n    onmessage\n    onmessage\n    onmessage\n    onclose\n    // ReconnectingWebSocket attempts to reconnect\n    onopen\n    onmessage\n    onmessage\n    onmessage\n    onclose\n\nThis is all handled automatically for you by the library.\n\n## Parameters\n\n```javascript\nvar socket = new ReconnectingWebSocket(url, protocols, options);\n```\n\n#### `url`\n- The URL you are connecting to.\n- https://html.spec.whatwg.org/multipage/comms.html#network\n\n#### `protocols`\n- Optional string or array of protocols per the WebSocket spec.\n- https://tools.ietf.org/html/rfc6455\n\n#### `options`\n- Options (see below)\n\n## Options\n\nOptions can either be passed as the 3rd parameter upon instantiation or set directly on the object after instantiation:\n\n```javascript\nvar socket = new ReconnectingWebSocket(url, null, {reconnectInterval: 3000});\n```\n\nor\n\n```javascript\nvar socket = new ReconnectingWebSocket(url);\nsocket.timeoutInterval = 5400;\n```\n\n#### `automaticOpen`\n- Whether or not the websocket should attempt to connect immediately upon instantiation. The socket can be manually opened or closed at any time using ws.open() and ws.close().\n- Accepts `true` or `false`\n- Default value: `true`\n\n#### `reconnectInterval`\n- The number of milliseconds to delay before attempting to reconnect.\n- Accepts `integer`\n- Default: `1000`\n\n#### `maxReconnectInterval`\n- The maximum number of milliseconds to delay a reconnection attempt.\n- Accepts `integer`\n- Default: `30000`\n\n####`reconnectDecay`\n- The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist.\n- Accepts `integer` or `float`\n- Default: `1.5`\n\n#### `timeoutInterval`\n- The maximum time in milliseconds to wait for a connection to succeed before closing and retrying.\n- Accepts `integer`\n- Default: `2000`\n\n#### `maxReconnectAttempts`\n- The maximum number of reconnection attempts that will be made before giving up. If null, reconnection attempts will be continue to be made forever.\n- Accepts `integer` or `null`.\n- Default: `null`\n\n#### `binaryType`\n- The binary type is required by some applications.\n- Accepts strings `'blob'` or `'arraybuffer'`.\n- Default: `'blob'`\n\n---\n\n## Methods\n\n#### `ws.open()`\n- Open the Reconnecting Websocket\n\n#### `ws.close(code, reason)`\n- Closes the WebSocket connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing.\n- `code` is optional the closing code (default value 1000). [https://tools.ietf.org/html/rfc6455#section-7.4.1](https://tools.ietf.org/html/rfc6455#section-7.4.1)\n- `reason` is the optional reason that the socket is being closed. [https://tools.ietf.org/html/rfc6455#section-7.1.6](https://tools.ietf.org/html/rfc6455#section-7.1.6)\n\n#### `ws.refresh()`\n- Refresh the connection if still open (close and then re-open it).\n\n#### `ws.send(data)`\n- Transmits data to the server over the WebSocket connection.\n- Accepts @param data a text string, ArrayBuffer or Blob\n\nLike this? Check out [websocketd](https://github.com/joewalnes/websocketd) for the simplest way to create WebSocket backends from any programming language.\n\n[Follow @joewalnes](https://twitter.com/joewalnes)\n","readmeFilename":"README.md"}