{"_id":"@airswap/jsonrpc-client-websocket","_rev":"2-cb0dd491901a08b0a8f64c20166cc7b5","name":"@airswap/jsonrpc-client-websocket","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@airswap/jsonrpc-client-websocket","version":"0.0.1","description":"JSON-RPC over WebSockets","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"test":"jest --config jestconfig.json","coverage":"jest --config jestconfig.json --coverage","build":"tsc","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tsc --noEmit && eslint . --ext .js,.jsx,.ts,.tsx --fix","prepublishOnly":"yarn test && yarn run lint","prepare":"yarn run build","preversion":"yarn run lint","version":"yarn run format && git add -A src","postversion":"git push && git push --tags"},"repository":{"type":"git","url":"git+https://github.com/airswap/jsonrpc-client-websocket"},"keywords":["websocket","jsonrpc","client","json","rpc"],"license":"MIT","devDependencies":{"@types/jest":"^27.0.2","@typescript-eslint/eslint-plugin":"^4.31.2","@typescript-eslint/parser":"^4.31.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-plugin-jest":"^24.4.2","jest":"^27.2.1","jest-websocket-mock":"^2.2.1","mock-socket":"^9.0.3","prettier":"^2.4.1","ts-jest":"^27.0.5","typescript":"^4.4.3"},"dependencies":{"get-parameter-names":"^0.3.0"},"publishConfig":{"access":"public"},"licenseText":"MIT License\n\nCopyright (c) 2019 Fabricio Bastian\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@airswap/jsonrpc-client-websocket@0.0.1","dist":{"shasum":"e75932a0f19cb6c23cf145834277211cce150400","integrity":"sha512-4S5iBAVzQKy+p3DgUr9OOKvKfBq1FHmbcgCYoVWSv5YBTVuaC4N03UHwKRjNXLcSUXXV/efl/sRjEQKm+ayklg==","tarball":"https://registry.npmjs.org/@airswap/jsonrpc-client-websocket/-/jsonrpc-client-websocket-0.0.1.tgz","fileCount":13,"unpackedSize":21505,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhwwPmCRA9TVsSAnZWagAAAV4P/R4HIKolyKf16gnmLaOU\n+DcxCROoip0svPQ7HoPycbT7E+Kg1mmXxnkT1Rgk+iet9aQL4hIUkojlj5Iv\nwPVFY+x8uUNzaeX+LCjdWX/7lWMsz4OSAtWY46Jui2hCCGNt8zhy5PTVFVuY\nZA/AcR2iaMXS+hqbIeHMqpU6scS1bSG7Rlgm4sHK0ACdSYRuFriDfSOMJHGc\nf6Eo/tJyXPkSNI6bajijyQFbTh4OTOrlPMhhdvzlBct56aoPcrCdvyZJwU8W\nLl+tnEhGHSFRzqbffft/Zu+zWI+uuFxUE3CgEnYUZ5caLIWyqnxxljif195f\nl0Mc1UPp33x9NHhoncX7rlJ+WuG5LPOdeEL3ehtT8OzWoIGIbb3tz2ayuVD7\nX0qtnJcIT3HMAz7dqF7UltX+zmRexZHM7hviPODarrIhB6BhrGL5BNJGa1YL\nmH6TPgoja1fhAUf6AL2Yxv/fujBylEAvI6Q8mAJTbFqEn+bpHvLkyKpUF12Y\nc+cn9OpXW1gTP4gj5dBlmx5ObrcvUq4sZ/tSB8g2trBGYnAG1vZw/qEgW/u9\nOe6IcmvaxfhJO3RAIddkmnBIDyHH9+Un0dnoYaLBWkL82hkoa8t50c2MGcTP\nDhdryujE7lBRIhcKebqKyEMHrXAwA0y3CRCfeuZJVZtg4fS587XfXJkgcxGr\nyRZ+\r\n=WGPh\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICMWMg2Hxz61WdM9yX/sykJezLS4iFiP8jwbvjfECtnmAiEAs4eVriISMLs0b4F2M7Job99DNnIhfBqkzJ69l6fhlds="}]},"_npmUser":{"name":"airswap","email":"opensource@airswap.io"},"directories":{},"maintainers":[{"name":"airswap","email":"opensource@airswap.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jsonrpc-client-websocket_0.0.1_1632305729371_0.136143704334579"},"_hasShrinkwrap":false}},"time":{"created":"2021-09-22T10:15:29.319Z","0.0.1":"2021-09-22T10:15:29.572Z","modified":"2022-04-04T12:23:20.018Z"},"maintainers":[{"name":"airswap","email":"opensource@airswap.io"}],"description":"JSON-RPC over WebSockets","keywords":["websocket","jsonrpc","client","json","rpc"],"repository":{"type":"git","url":"git+https://github.com/airswap/jsonrpc-client-websocket"},"license":"MIT","readme":"# JSON-RPC 2.0 Client over WebSockets\n\nForked from https://github.com/fabriciobastian/jsonrpc-client-websocket\n\n## Open connection\n\n```typescript\nconst websocketUrl = 'ws://mywebsocketurl:port';\nconst requestTimeoutMs = 2000;\nconst websocket = new JsonRpcWebsocket(websocketUrl, requestTimeoutMs, (error: JsonRpcError) => {\n  /* handle error */\n});\nawait websocket.open();\n```\n\nRequests that do not receive a response within the specified timeout will fail with a REQUEST_TIMEOUT code.\nThe callback (optional) is used for eventual errors, such as receiving a response that does not match any request id and\nconnection errors. Furthermore, all errors that are sent to an eventual caller are also reported on the callback, e.g.\nif an rpc method is called with an invalid number of parameters, etc...\n\n## Close connection\n\n```typescript\nawait websocket.close();\n```\n\n## Call RPC method\n\nConsidering that the server has a method `sum(a: int, b: int)`\n\n### with positional parameters\n\n```typescript\nwebsocket\n  .call('sum', [1, 2])\n  .then((response) => {\n    // handle response\n  })\n  .catch((error) => {\n    // handle error\n  });\n```\n\n### with named parameters\n\n```typescript\nwebsocket\n  .call('sum', { b: 1, a: 2 })\n  .then((response) => {\n    // handle response\n  })\n  .catch((error) => {\n    // handle error\n  });\n```\n\n## Send notification\n\nConsidering that the server has a method `log(message: string)`\n\n```typescript\nwebsocket.notify('log', ['a log message']);\n```\n\n## Define RPC method\n\n```typescript\nwebsocket.on('sum', (a: number, b: number) => {\n  return a + b;\n});\n```\n\nThe defined RPC methods can also be called with both positional and named parameters.\n\n## Remove RPC method\n\n```typescript\nwebsocket.off('sum');\n```\n","readmeFilename":"README.md"}