{"_id":"@6thquake/inohupwebsocket","_rev":"4-83f61605117cb6d4e95b567aae97ce3a","name":"@6thquake/inohupwebsocket","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@6thquake/inohupwebsocket","version":"0.1.0","description":"nohup websocket client with karn, ping pong, sub, friendly api and so on.","main":"dist/NohupWebSocket.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"gulp"},"author":{"name":"lico, jxzhuang, yx_zhang"},"contributors":[],"developers":[{"id":"lico.liu","name":"lico.liu","email":"lico.atom@gmail.com","url":"https://github.com/licoliu"},{"id":"jxzhuang","name":"jxzhuang","url":"https://github.com/JX-Zhuang"},{"id":"yx_zhang","name":"yx_zhang"}],"license":"MIT","dependencies":{"q":"1.0.1"},"private":false,"devDependencies":{"gulp":"^3.9.1","gulp-concat":"^2.6.1","gulp-uglifyjs":"^0.6.2","gulp-umd":"^0.2.1","gulp-watch":"^5.0.0"},"gitHead":"97436bad03b67ec4963f944b00e3adb8b071e84f","_id":"@6thquake/inohupwebsocket@0.1.0","_shasum":"c29dc6f44f2504a8d526eb68bfe41904b85d4a98","_from":".","_npmVersion":"2.15.0","_nodeVersion":"4.4.2","_npmUser":{"name":"lico","email":"lico.atom@gmail.com"},"dist":{"shasum":"c29dc6f44f2504a8d526eb68bfe41904b85d4a98","tarball":"https://registry.npmjs.org/@6thquake/inohupwebsocket/-/inohupwebsocket-0.1.0.tgz","fileCount":13,"unpackedSize":106322,"integrity":"sha512-NuqS4olYR8hLMISIF1lUawuTeUboMTrY5tJkg8ILTrkp7d0BhDOo+cPFXmg7bif+IhXVJAt/60gD479MH+VE/A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEnc8g/hbhCXz0zjlmCAwhSJekjKzr2gP434GUMlbAENAiBsL2dJ5+rLfsrefmq4S93WgN6codtkiypSai74HIY/CQ=="}]},"maintainers":[{"name":"lico","email":"lico.atom@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/inohupwebsocket_0.1.0_1532078759878_0.19603742595259188"},"_hasShrinkwrap":false},"0.1.1":{"name":"@6thquake/inohupwebsocket","version":"0.1.1","description":"nohup websocket client with karn, ping pong, sub, friendly api and so on.","main":"dist/NohupWebSocket.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"gulp"},"author":{"name":"lico, jxzhuang, yx_zhang"},"contributors":[],"developers":[{"id":"lico.liu","name":"lico.liu","email":"lico.atom@gmail.com","url":"https://github.com/licoliu"},{"id":"jxzhuang","name":"jxzhuang","url":"https://github.com/JX-Zhuang"},{"id":"yx_zhang","name":"yx_zhang"}],"license":"MIT","dependencies":{"q":"1.0.1"},"private":false,"devDependencies":{"gulp":"^3.9.1","gulp-concat":"^2.6.1","gulp-uglifyjs":"^0.6.2","gulp-umd":"^0.2.1","gulp-watch":"^5.0.0"},"gitHead":"e10c01a6d92df72ba59bd6d53c5200b37f372766","_id":"@6thquake/inohupwebsocket@0.1.1","_shasum":"8266d45548815423e347901033382d1f3488dda9","_from":".","_npmVersion":"2.15.0","_nodeVersion":"4.4.2","_npmUser":{"name":"lico","email":"lico.atom@gmail.com"},"dist":{"shasum":"8266d45548815423e347901033382d1f3488dda9","tarball":"https://registry.npmjs.org/@6thquake/inohupwebsocket/-/inohupwebsocket-0.1.1.tgz","fileCount":13,"unpackedSize":106468,"integrity":"sha512-Ny/iQNKfEosQG6t7YhkaXiwsCWgpLM3vpWCS4e2sUcCi8Md9AgCHzfgL1kB4RwGZQeH8WZhyCInW/V7pqu/rzg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCcuOG9++TAsFo5H+6LydEq/Vyi57j2CD5Zk7X+86AiPQIhAJVt0i2fypqaXxOAtwIzgGd4H7XY3dz3vBafYAO+UZsA"}]},"maintainers":[{"name":"lico","email":"lico.atom@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/inohupwebsocket_0.1.1_1532079182680_0.9701072308917893"},"_hasShrinkwrap":false}},"time":{"created":"2018-07-20T09:25:59.654Z","0.1.0":"2018-07-20T09:26:00.007Z","modified":"2022-06-12T14:11:55.653Z","0.1.1":"2018-07-20T09:33:02.743Z"},"maintainers":[{"email":"1182025989@qq.com","name":"chaos233"},{"email":"lico.atom@gmail.com","name":"lico"}],"description":"nohup websocket client with karn, ping pong, sub, friendly api and so on.","contributors":[],"author":{"name":"lico, jxzhuang, yx_zhang"},"license":"MIT","readme":"# iNohupWebSocket\n> Websocket工具类，除支持原生Websocket方法外，还支持自动重连、Ping Pong、Notification的操作，接收服务端消息后的api封装处理，消息订阅等。\n\n### Requirements\n1. \n  ```javascript\n  q >= 1.5.1\n  ```\n\n### install \n  * using npm\n  ```bash\n  $ npm install @6thquake/inohupwebsocket\n  ``` \n  * using yarn\n  ```bash\n  $ yarn add @6thquake/inohupwebsocket\n  ``` \n  \n### build \n  * gulp\n  ```bash\n  $ npm install gulp\n  ```  \n  * dependencies\n  ```bash\n  $ npm install\n  ```   \n  * build\n  ```bash\n  $ gulp\n  ```\n\n### Usage\n1. 在html里引入q、iNohupWebSocket\n    ```html\n    <script type=\"text/javascript\" src=\"http://apps.bdimg.com/libs/q.js/2.0.1/q.js\"></script>\n    <script type=\"text/javascript\" src=\"https://github.com/6thquake/iNohupWebSocket/tree/master/dist/NohupWebSocket.js\"></script>\n    ```\n2. 初始化\n    ```javascript\n    var ws = NohupWebSocket.getInstance('ws://xxx', protocol, options);\n    // 参数和原生websocket的参数保持一致，options多了两个可选属性 maxReconnectWaitTime reconnectBaseTime\n    // maxReconnectWaitTime:重连最大等待时间，默认30s\n    // reconnectBaseTime:重连采用指数退避算法，reconnectBaseTime为底数，默认2\n    ```\n3. 基本功能\n\n   1. 设置事件处理函数（onopen、onclose、onconnecting、onmessage、onerror）\n      ```javascript\n      ws.onopen = function(event){};\n      ws.onconnecting = function(event){};\n      ws.onmessage = function(event){};\n      ws.onerror = function(event){};\n      ws.onclose = function(event){};\n      ```\n   \n   2. 发送消息（send）\n      ```javascript\n      ws.send({\n        url: 'tsbot/cases/437'\n      }).then(function (data) {\n        console.log(\"success\");\n      }, function (err) {\n        console.log(\"error\");\n      }, function (n) {\n        console.log(\"fially\");\n      });\n      ```\n        \n   3. 消息订阅（sub、psub、unsub、unpsub）\n      ```javascript\n      /**\n       * 1. 客户端send数据：此接口模拟http协议，提供url来确定频道，可以使用restful接口来定义和后端服务的映射关系，\n       * 参数可以放在链接上也可以通过?来分隔链接和参数，e.g.\n       *    1. { url: 'users/1', method:'GET' }\n       *    2. { url: 'users/1?name=xxx' }\n       *\n       * 2. 服务端响应：对应服务端需要将请求的数据返回回来，e.g.\n       *    {\n       *      request: {\n       *         url: 'users/1'\n       *      },\n       *      data: {}, //数据\n       *      type: 'NOTIFICATION' // 可选 NOTIFICATION（自动调用浏览器的Notification api）\n       *    }\n       *\n       * 3. 对应的客户端处理数据：\n       *  ws.sub({\n       *     url: 'users/1'\n       *  }).then(success, error, finally);\n       *\n       *  ws.psub({\n       *     url: 'users/*'\n       *  }).progress(function(data){});\n       *  \n       *  ws.notification().progress(function(data){}); // 处理服务端返回的type为NOTIFICATION的所有消息\n       */\n\n      // 按频道订阅 \n      ws.sub({\n        url: \"tsbot/cases/437\"\n      }).then(function (data) {\n        console.log(\"success\");\n      }, function (err) {\n        console.log(\"error\");\n      }, function (n) {\n        console.log(\"fially\");\n      });\n      \n      // 支持按正则表达式订阅\n      ws.psub({\n        url: \"tsbot/cases/*\"\n      }).progress(function (data) {\n        console.log(\"success\");\n      };\n\n      // 按频道解除订阅\n      ws.unsub({\n        url: \"tsbot/cases/437\"\n      })\n\n      // 按正则解除订阅\n      ws.unpsub({\n        url: \"tsbot/cases/*\"\n      })\n      ```\n\n   4. close 、refresh\n      ```javascript\n\n      ws.refresh();\n\n      ws.close();\n\n      ```\n\n###### 需要引入[Q](https://github.com/kriskowal/q)，支持AMD、CMD \n\n","readmeFilename":"README.md"}