{"_id":"@web3-js/websocket","_rev":"8-cc97b832567e614b865fffb60c6776a3","name":"@web3-js/websocket","dist-tags":{"latest":"1.0.30"},"versions":{"1.0.29":{"name":"@web3-js/websocket","description":"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.","keywords":["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],"author":{"name":"Brian McKelvey","email":"theturtle32@gmail.com","url":"https://github.com/theturtle32"},"contributors":[{"name":"Iñaki Baz Castillo","email":"ibc@aliax.net","url":"http://dev.sipdoc.net"}],"version":"1.0.29","repository":{"type":"git","url":"git+https://github.com/web3-js/WebSocket-Node.git"},"homepage":"https://github.com/web3-js/WebSocket-Node","engines":{"node":">=0.10.0"},"dependencies":{"debug":"^2.2.0","es5-ext":"^0.10.50","nan":"^2.14.0","typedarray-to-buffer":"^3.1.5","yaeti":"^0.0.6"},"devDependencies":{"buffer-equal":"^1.0.0","faucet":"^0.0.1","gulp":"^4.0.2","gulp-jshint":"^2.0.4","jshint-stylish":"^2.2.1","jshint":"^2.0.0","tape":"^4.9.1"},"config":{"verbose":false},"scripts":{"install":"(node-gyp rebuild 2> builderror.log) || (exit 0)","test":"faucet test/unit","gulp":"gulp"},"main":"index","directories":{"lib":"./lib"},"browser":"lib/browser.js","license":"Apache-2.0","gitHead":"905deb4812572b344f5801f8c9ce8bb02799d82e","bugs":{"url":"https://github.com/web3-js/WebSocket-Node/issues"},"_id":"@web3-js/websocket@1.0.29","_nodeVersion":"12.11.1","_npmVersion":"6.11.3","dist":{"integrity":"sha512-QDr5mwRd50qcaIc91yqhpA6CAKgkFBBSPpshlkpU6qDPdtrZoch+AOcUpzGgQHpgg7nvfCtU9VYbnShv8uusJA==","shasum":"542b8e28b02ba57642085ac35f1767a8f088f6a1","tarball":"https://registry.npmjs.org/@web3-js/websocket/-/websocket-1.0.29.tgz","fileCount":36,"unpackedSize":172176,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdutuWCRA9TVsSAnZWagAAMvcP+QEF8BxMopEhaoSIJtH/\noAGnV8/1l4uEUlrb68rn8L0YLIiS9tC6nR02dc38WIJMO7dtA2FcElALfUwj\n95vWJJMKY8lS/plf0vWeI7yb6OKFgJewL1B+ZmfiQomxmk0nk53YG3Ug5CG1\n7CIbUeyxnM8L/M1hzYk+imA5N+tFvBkKVC45KcxMAtB+tg8+tZrGBzQVk34S\npC8O/O5SgP/o5gbOIPKPp4vZJyv/yBW1QhZeiI4iqTedoU2osipjeMwQNTs7\nO1TGRH3lsKbYfhSPFXFW3FG0k9WEYJtg6deTWi3EM+KhzTDsBKHxltWShWrA\nomJm/UNhSBsrLVlAQAujjcYbkrXVV4/cT0iFXri7PbzQOI4xhzk2L1kTJzng\nPIykFdd0pvRCcFzP4U3iOZ0VJ3udIJYz+Ujr+z0Y6qO6yHHXZDcBkDwUeCgB\nwhJ0iJfIZY8N2hFxJlqpYOmO/sUNtTf4l0Gk8gu/KHvBn6yiw1g2UyfFhSxv\ndd+lD4oT1JtIsqC7mduzMZGX0tss0H8fwz1xbEcfIzO9NjWIKRRfaXrlqWVr\n8W4mQnmKuGcv64r3ibCFI72+SwpphicdcoKvpZx48XeJrQbDPDdBl4aTsVLI\nH4345duZaXfHTCuFDYdFoUwG6hbKOny296NY/RbQE+OjD9RX/hzZvRQJbGD2\nIvKJ\r\n=kFuC\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDhT3kBy5R0umTuZXsGpel43zCLf2A0+33SB7kGHLl7mwIgHjOl2Q6BmH7j5vVAMWyhzLDS3WanNLutpdUh9j+jA0A="}]},"maintainers":[{"name":"nivida","email":"samuel@ethereum.org"}],"_npmUser":{"name":"nivida","email":"samuel@ethereum.org"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/websocket_1.0.29_1572526998185_0.6526477670088129"},"_hasShrinkwrap":false,"deprecated":"The branch for this fork was merged upstream, please update your package to websocket@1.0.31"},"1.0.30":{"name":"@web3-js/websocket","description":"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.","keywords":["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],"author":{"name":"Brian McKelvey","email":"theturtle32@gmail.com","url":"https://github.com/theturtle32"},"contributors":[{"name":"Iñaki Baz Castillo","email":"ibc@aliax.net","url":"http://dev.sipdoc.net"}],"version":"1.0.30","repository":{"type":"git","url":"git+https://github.com/web3-js/WebSocket-Node.git"},"homepage":"https://github.com/web3-js/WebSocket-Node","engines":{"node":">=0.10.0"},"dependencies":{"debug":"^2.2.0","es5-ext":"^0.10.50","nan":"^2.14.0","typedarray-to-buffer":"^3.1.5","yaeti":"^0.0.6"},"devDependencies":{"buffer-equal":"^1.0.0","faucet":"^0.0.1","gulp":"^4.0.2","gulp-jshint":"^2.0.4","jshint-stylish":"^2.2.1","jshint":"^2.0.0","tape":"^4.9.1"},"config":{"verbose":false},"scripts":{"install":"(node-gyp rebuild 2> builderror.log) || (exit 0)","test":"faucet test/unit","gulp":"gulp"},"main":"index","directories":{"lib":"./lib"},"browser":"lib/browser.js","license":"Apache-2.0","gitHead":"b8cce6cad1aad53cda2c082830617f2c817cb758","bugs":{"url":"https://github.com/web3-js/WebSocket-Node/issues"},"_id":"@web3-js/websocket@1.0.30","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-fDwrD47MiDrzcJdSeTLF75aCcxVVt8B1N74rA+vh2XCAvFy4tEWJjtnUtj2QG7/zlQ6g9cQ88bZFBxwd9/FmtA==","shasum":"9ea15b7b582cf3bf3e8bc1f4d3d54c0731a87f87","tarball":"https://registry.npmjs.org/@web3-js/websocket/-/websocket-1.0.30.tgz","fileCount":29,"unpackedSize":162762,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdxv+FCRA9TVsSAnZWagAAh68P/1vscTl18CbAVKhZONKh\nLcmOH0c9tSFvNkeNMlnme+ZVAP+XV01Ww8LnLBb1c6Un117soLd8+Lu2U+Cq\nDwT/BRCkQNnV5yKG5cC8D0SKPq7iuJpbuRub/DmAnmym5aNLQdjakk+pGaMR\nt2jQjKk3v5L1pI1C0karvZS5sxHsAC34w6znEJ853jUpQty2N1/AlHWd+ct5\nN+GCq7zZIiTB5T3Y/kNnevs9R0V2rNd1PpFyLeU+1Ml+5mEaOTMUsX7HsxvR\n8uLM5Kxp6VQAK0AgzDBWh+K47nJAPK1ACmBBtbRAAT96MIxj/9cIIvV5FeR3\n2CziD3HIM156LP+vGiGjGfqCtICKBr5Tye/UixTr1qv3T+cf+6ULhExXh3m0\nGnU9CAfdET0GNdtv/fkr+1mXb0WMOobPeS5NYAcPCxRwG6wAGNjokQ9MUrsS\nlWdxvECAsLXyATptWCVkhwoj2cSP9KieqwPDodqM6DLNYNgHrdub5KV2UHcX\n4VLpr/jypqzJ/uuNLGOkqjbBv8pdpzZ+4PTRegKS4pej7jtvokuh+N6X1MvT\n/ZUM2Mr4RLNMUDzHEo2muHYlGTgkibCAzAsc5QF/nMHUtW0oyqsiPu8wnA7F\nT7n8jmHeebfaejKBugLI6bqGp5zSqIp7M8jvb+ZNufYhtd/Ox/CQr27vpUL+\nVNgX\r\n=e262\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDmMph71FktkA6NF4pUiOZNkAamU9IORDmwOFao4k++IQIhAIqdmnSkICsNZODwKO28lPfUx1eY2V5iHPqVQTGmu3RG"}]},"maintainers":[{"name":"nivida","email":"samuel@ethereum.org"}],"_npmUser":{"name":"nivida","email":"samuel@ethereum.org"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/websocket_1.0.30_1573322628443_0.06293571506011952"},"_hasShrinkwrap":false,"deprecated":"The branch for this fork was merged upstream, please update your package to websocket@1.0.31"}},"time":{"created":"2019-10-31T13:03:17.971Z","1.0.29":"2019-10-31T13:03:18.283Z","modified":"2023-02-27T09:54:56.232Z","1.0.30":"2019-11-09T18:03:48.664Z"},"maintainers":[{"email":"Holger.Drewes@gmail.com","name":"holgerd77"},{"email":"gregorymarkou@gmail.com","name":"gregthegreek"}],"description":"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.","homepage":"https://github.com/web3-js/WebSocket-Node","keywords":["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],"repository":{"type":"git","url":"git+https://github.com/web3-js/WebSocket-Node.git"},"contributors":[{"name":"Iñaki Baz Castillo","email":"ibc@aliax.net","url":"http://dev.sipdoc.net"}],"author":{"name":"Brian McKelvey","email":"theturtle32@gmail.com","url":"https://github.com/theturtle32"},"bugs":{"url":"https://github.com/web3-js/WebSocket-Node/issues"},"license":"Apache-2.0","readme":"WebSocket Client & Server Implementation for Node\n=================================================\n\n[![npm version](https://badge.fury.io/js/websocket.svg)](http://badge.fury.io/js/websocket)\n\n[![NPM Downloads](https://img.shields.io/npm/dm/websocket.svg)](https://www.npmjs.com/package/websocket)\n\n[![NPM](https://nodei.co/npm/websocket.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/websocket/)\n\n[![NPM](https://nodei.co/npm-dl/websocket.png?height=3)](https://nodei.co/npm/websocket/)\n\n[ ![Codeship Status for theturtle32/WebSocket-Node](https://codeship.com/projects/70458270-8ee7-0132-7756-0a0cf4fe8e66/status?branch=master)](https://codeship.com/projects/61106)\n\nOverview\n--------\nThis is a (mostly) pure JavaScript implementation of the WebSocket protocol versions 8 and 13 for Node.  There are some example client and server applications that implement various interoperability testing protocols in the \"test/scripts\" folder.\n\nFor a WebSocket client written in ActionScript 3, see my [AS3WebScocket](https://github.com/theturtle32/AS3WebSocket) project.\n\n\nDocumentation\n=============\n\n[You can read the full API documentation in the docs folder.](docs/index.md)\n\n\nChangelog\n---------\n\n***Current Version: 1.0.29*** — Released 2019-07-03\n\n* Updated some dependencies and updated the .gitignore and .npmignore files\n\n[View the full changelog](CHANGELOG.md)\n\nBrowser Support\n---------------\n\nAll current browsers are fully supported.\n\n* Firefox 7-9 (Old) (Protocol Version 8)\n* Firefox 10+ (Protocol Version 13)\n* Chrome 14,15 (Old) (Protocol Version 8)\n* Chrome 16+ (Protocol Version 13)\n* Internet Explorer 10+ (Protocol Version 13)\n* Safari 6+ (Protocol Version 13)\n\n***Safari older than 6.0 is not supported since it uses a very old draft of WebSockets***\n\n***If you need to simultaneously support legacy browser versions that had implemented draft-75/draft-76/draft-00, take a look here: https://gist.github.com/1428579***\n\nBenchmarks\n----------\nThere are some basic benchmarking sections in the Autobahn test suite.  I've put up a [benchmark page](http://theturtle32.github.com/WebSocket-Node/benchmarks/) that shows the results from the Autobahn tests run against AutobahnServer 0.4.10, WebSocket-Node 1.0.2, WebSocket-Node 1.0.4, and ws 0.3.4.\n\nAutobahn Tests\n--------------\nThe very complete [Autobahn Test Suite](http://autobahn.ws/testsuite/) is used by most WebSocket implementations to test spec compliance and interoperability.\n\n- [View Server Test Results](http://theturtle32.github.com/WebSocket-Node/test-report/servers/)\n\nInstallation\n------------\n\nA few users have reported difficulties building the native extensions without first manually installing node-gyp.  If you have trouble building the native extensions, make sure you've got a C++ compiler, and have done `npm install -g node-gyp` first. \n\nNative extensions are optional, however, and WebSocket-Node will work even if the extensions cannot be compiled.\n\nIn your project root:\n\n    $ npm install websocket\n  \nThen in your code:\n\n```javascript\nvar WebSocketServer = require('websocket').server;\nvar WebSocketClient = require('websocket').client;\nvar WebSocketFrame  = require('websocket').frame;\nvar WebSocketRouter = require('websocket').router;\nvar W3CWebSocket = require('websocket').w3cwebsocket;\n```\n\nNote for Windows Users\n----------------------\nBecause there is a small C++ component used for validating UTF-8 data, you will need to install a few other software packages in addition to Node to be able to build this module:\n\n- [Microsoft Visual C++](http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express)\n- [Python 2.7](http://www.python.org/download/) (NOT Python 3.x)\n\n\nCurrent Features:\n-----------------\n- Licensed under the Apache License, Version 2.0\n- Protocol version \"8\" and \"13\" (Draft-08 through the final RFC) framing and handshake\n- Can handle/aggregate received fragmented messages\n- Can fragment outgoing messages\n- Router to mount multiple applications to various path and protocol combinations\n- TLS supported for outbound connections via WebSocketClient\n- TLS supported for server connections (use https.createServer instead of http.createServer)\n  - Thanks to [pors](https://github.com/pors) for confirming this!\n- Cookie setting and parsing\n- Tunable settings\n  - Max Receivable Frame Size\n  - Max Aggregate ReceivedMessage Size\n  - Whether to fragment outgoing messages\n  - Fragmentation chunk size for outgoing messages\n  - Whether to automatically send ping frames for the purposes of keepalive\n  - Keep-alive ping interval\n  - Whether or not to automatically assemble received fragments (allows application to handle individual fragments directly)\n  - How long to wait after sending a close frame for acknowledgment before closing the socket.\n- [W3C WebSocket API](http://www.w3.org/TR/websockets/) for applications running on both Node and browsers (via the `W3CWebSocket` class). \n\n\nKnown Issues/Missing Features:\n------------------------------\n- No API for user-provided protocol extensions.\n\n\nUsage Examples\n==============\n\nServer Example\n--------------\n\nHere's a short example showing a server that echos back anything sent to it, whether utf-8 or binary.\n\n```javascript\n#!/usr/bin/env node\nvar WebSocketServer = require('websocket').server;\nvar http = require('http');\n\nvar server = http.createServer(function(request, response) {\n    console.log((new Date()) + ' Received request for ' + request.url);\n    response.writeHead(404);\n    response.end();\n});\nserver.listen(8080, function() {\n    console.log((new Date()) + ' Server is listening on port 8080');\n});\n\nwsServer = new WebSocketServer({\n    httpServer: server,\n    // You should not use autoAcceptConnections for production\n    // applications, as it defeats all standard cross-origin protection\n    // facilities built into the protocol and the browser.  You should\n    // *always* verify the connection's origin and decide whether or not\n    // to accept it.\n    autoAcceptConnections: false\n});\n\nfunction originIsAllowed(origin) {\n  // put logic here to detect whether the specified origin is allowed.\n  return true;\n}\n\nwsServer.on('request', function(request) {\n    if (!originIsAllowed(request.origin)) {\n      // Make sure we only accept requests from an allowed origin\n      request.reject();\n      console.log((new Date()) + ' Connection from origin ' + request.origin + ' rejected.');\n      return;\n    }\n    \n    var connection = request.accept('echo-protocol', request.origin);\n    console.log((new Date()) + ' Connection accepted.');\n    connection.on('message', function(message) {\n        if (message.type === 'utf8') {\n            console.log('Received Message: ' + message.utf8Data);\n            connection.sendUTF(message.utf8Data);\n        }\n        else if (message.type === 'binary') {\n            console.log('Received Binary Message of ' + message.binaryData.length + ' bytes');\n            connection.sendBytes(message.binaryData);\n        }\n    });\n    connection.on('close', function(reasonCode, description) {\n        console.log((new Date()) + ' Peer ' + connection.remoteAddress + ' disconnected.');\n    });\n});\n```\n\nClient Example\n--------------\n\nThis is a simple example client that will print out any utf-8 messages it receives on the console, and periodically sends a random number.\n\n*This code demonstrates a client in Node.js, not in the browser*\n\n```javascript\n#!/usr/bin/env node\nvar WebSocketClient = require('websocket').client;\n\nvar client = new WebSocketClient();\n\nclient.on('connectFailed', function(error) {\n    console.log('Connect Error: ' + error.toString());\n});\n\nclient.on('connect', function(connection) {\n    console.log('WebSocket Client Connected');\n    connection.on('error', function(error) {\n        console.log(\"Connection Error: \" + error.toString());\n    });\n    connection.on('close', function() {\n        console.log('echo-protocol Connection Closed');\n    });\n    connection.on('message', function(message) {\n        if (message.type === 'utf8') {\n            console.log(\"Received: '\" + message.utf8Data + \"'\");\n        }\n    });\n    \n    function sendNumber() {\n        if (connection.connected) {\n            var number = Math.round(Math.random() * 0xFFFFFF);\n            connection.sendUTF(number.toString());\n            setTimeout(sendNumber, 1000);\n        }\n    }\n    sendNumber();\n});\n\nclient.connect('ws://localhost:8080/', 'echo-protocol');\n```\n\nClient Example using the *W3C WebSocket API*\n--------------------------------------------\n\nSame example as above but using the [W3C WebSocket API](http://www.w3.org/TR/websockets/).\n\n```javascript\nvar W3CWebSocket = require('websocket').w3cwebsocket;\n\nvar client = new W3CWebSocket('ws://localhost:8080/', 'echo-protocol');\n\nclient.onerror = function() {\n    console.log('Connection Error');\n};\n\nclient.onopen = function() {\n    console.log('WebSocket Client Connected');\n\n    function sendNumber() {\n        if (client.readyState === client.OPEN) {\n            var number = Math.round(Math.random() * 0xFFFFFF);\n            client.send(number.toString());\n            setTimeout(sendNumber, 1000);\n        }\n    }\n    sendNumber();\n};\n\nclient.onclose = function() {\n    console.log('echo-protocol Client Closed');\n};\n\nclient.onmessage = function(e) {\n    if (typeof e.data === 'string') {\n        console.log(\"Received: '\" + e.data + \"'\");\n    }\n};\n```\n    \nRequest Router Example\n----------------------\n\nFor an example of using the request router, see `libwebsockets-test-server.js` in the `test` folder.\n\n\nResources\n---------\n\nA presentation on the state of the WebSockets protocol that I gave on July 23, 2011 at the LA Hacker News meetup.  [WebSockets: The Real-Time Web, Delivered](http://www.scribd.com/doc/60898569/WebSockets-The-Real-Time-Web-Delivered)\n","readmeFilename":"README.md"}