{"_id":"@akanass/rx-socket-client","_rev":"6-0aaa1a734790f50893c061f3e5923c56","name":"@akanass/rx-socket-client","dist-tags":{"latest":"2.1.0"},"versions":{"1.0.0":{"name":"@akanass/rx-socket-client","version":"1.0.0","keywords":["RxJS","Rx","ReactiveX","Observable","Observer","Subject","Socket","WebSocket","Streams","Async","ES2015","ES2016","ES2017","ES6","ES7","ES8","Typescript","Browser"],"license":"SEE LICENSE IN https://github.com/njl07/rx-socket-client/blob/master/LICENSE.md","_id":"@akanass/rx-socket-client@1.0.0","maintainers":[{"name":"akanass","email":"akanass@icloud.com"}],"contributors":[{"url":"https://github.com/njl07","name":"Nicolas Jessel"}],"homepage":"https://github.com/njl07/rx-socket-client#readme","bugs":{"url":"https://github.com/njl07/rx-socket-client/issues"},"dist":{"shasum":"8aad2c247effd027cfcad100cc3d5ee41e459f0b","tarball":"https://registry.npmjs.org/@akanass/rx-socket-client/-/rx-socket-client-1.0.0.tgz","fileCount":26,"integrity":"sha512-srMqAmIei1rsmi7ToPQrR0GENOvnYjHdXzNzGIsgZbeqbuyMSs47uiuRkalm5veEqy64tVsaaJf6Pdh1rux/xw==","signatures":[{"sig":"MEYCIQCoYi5L1gbKRe+KEBxiM1zBqHy8iftOPZNPwQlPwFmOpQIhAOZdLBSsW0Qj4XoZAP03D0fBruqsApXrYutRtITei6Yr","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1659321,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa/BRfCRA9TVsSAnZWagAALQoP/1Y+lzajgMbuKUGZCIVL\nET+p6+pfzw28UoESaq1B1igN5EOyKHXnRKzClMjRDpefUN9fdDDSmQRO0c8z\n1CFK3NXi9rVK9Vbv+4v2FCPPEwaeoDFX9SA0ZRhtu/ADg8uDDTXVf2Sbrpds\nlZ8ZWgLyInV2/2YVF57Qd/i12anhX6SwdzvWt+eu6SvbREaQqiLI4fqszxaD\n5jffEhcg+rXhHrFeb3DGrnr8ztC89d2c13g4xzLYYrQYXAic75BJd8Joc+GM\ni/dXtkUAdwbWrFTRvEO6UhWLnrKM3WufX6Hh0Lewp2Pds7Qokw1IwWchp4Od\nV479gWPLNMRm7IB5fikbI9FPqzFGA61EoqYFQLvqfo74zVb73z92UHzwbyMU\n2g2zvp9TkedYiftUZ/FZ/pG1GZsx5xkNPhERk1VdTHkzieGLAkjvvwj9xA8a\nOZwqte0sLXkbw8KmAp9hU2XruIswqL+3HsnrPYexkk6Bg58zxZrgQUp2tXPM\nkbpTMj9MB53Nmv8VJoE9CP26NKoqg1mNcDpeLm5MaOZ7HWJiyc9tOaoLkN/Z\n5kqE18PTIC1jrNh4rVWxFb9yUbVdmaxM8KwUkx562sM4J8nHh3r8oXXoU/Ki\n95OsrbclKzBj6qIcGaqEdycNci2jkOEUI3ez+hKbVP53E6k83D9VBnjOV+TT\nNA0Q\r\n=71Vk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"commonjs/index.js","types":"index.d.ts","es2015":"esm2015/index.js","module":"esm5/index.js","engines":{"node":">=7.0.0"},"private":false,"_npmUser":{"name":"akanass","email":"akanass@icloud.com"},"repository":{"url":"git+ssh://git@github.com/njl07/rx-socket-client.git","type":"git"},"_npmVersion":"6.0.1","description":"Reconnectable websocket client with RxJS Subject","directories":{},"_nodeVersion":"10.1.0","dependencies":{"websocket":"^1.0.26","@types/node":"^10.1.0"},"_hasShrinkwrap":false,"peerDependencies":{"rxjs":"^6.1.0"},"_npmOperationalInternal":{"tmp":"tmp/rx-socket-client_1.0.0_1526469726165_0.5314382757935183","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"@akanass/rx-socket-client","version":"1.1.0","keywords":["RxJS","Rx","ReactiveX","Observable","Observer","Subject","Socket","WebSocket","Streams","Async","ES2015","ES2016","ES2017","ES6","ES7","ES8","Typescript","Browser"],"license":"SEE LICENSE IN https://github.com/njl07/rx-socket-client/blob/master/LICENSE.md","_id":"@akanass/rx-socket-client@1.1.0","maintainers":[{"name":"akanass","email":"akanass@icloud.com"}],"contributors":[{"url":"https://github.com/njl07","name":"Nicolas Jessel"}],"homepage":"https://github.com/njl07/rx-socket-client#readme","bugs":{"url":"https://github.com/njl07/rx-socket-client/issues"},"dist":{"shasum":"cf09a22dc95eab0ac639e6095b2020babf64e16c","tarball":"https://registry.npmjs.org/@akanass/rx-socket-client/-/rx-socket-client-1.1.0.tgz","fileCount":26,"integrity":"sha512-JtBpCD0DRD8cBu8e/skOfRsJF6e0Os72VZEYnKvIiEreMeXmASZV+9CAuOu373KazqLzSXd+qkwHd9TLF+ylbA==","signatures":[{"sig":"MEUCIQDk+enJeW75QJcjQnGhUJ60jVtcFnV0SGK2gIoi8RzFfQIgZwQ4Wzv92FnnJ+mTMwd8ntVInvW+PtG+LR5VY4+UPYY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1652242,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbD/j/CRA9TVsSAnZWagAAPloP/0VgqKvRy7F2jYiRUF2A\nQFztuhNJsft2b3fkTI9in++eLYBmgEqudGEvRD5k7wCQYWw1q2QN8mvfz6AR\n+xnTvgZY0gInkCvGivk0s2ihL1u1YdCuGgLH+vwcj9VQUA6CCvKqPDzjMlEV\n9Fzg3KLBpANsmOe+HsQC0eX/Iq8I2xr1soFQNPT7KmU/2g3M74p2Nvc60CM6\nEWDsmD3b3lXti1cp1gEnBMohhFt7AZ2RI1FALUZoCi47rSkyA2lRIxsv+Q3P\n+f/GdcmzBkKP/4z8/lKFEfqL2NhRJQuya6QuhBP3khp3fIE7Z+aLyyKK0aOx\nAT11QnstwAouI2FGjyjp6lDGOifAwNQTHF/mT5LoZxxY7to7twI8+y1KCPgi\nzUHYC9xxylxQfwnBnu38kEOeZpWfBr0BSngvbFUai/rMsHzkC//NQK2OPT7d\nuwiIZN8RHYj2tOk0/4TM//8RmfVmSbDoU+r0/Hd/w2CK2DeypLa5TvvFtdfz\ngFi2amHPMvxRJUA50HQE8DDg95FRHA3/j1Va/r7pYeTH7ltReRFwjD9erY6X\n99u5FjYNlvnA76+XBsBQvUM6I2shx1yM2ajpL/uYvmhxiZjl/SC4aQ6UXqPi\n30ZqLjeO5EUa59doEzCBkyctOOfsY5KC02RhK5H3LSvblXua616ocYZEBdsG\nGbcn\r\n=nUZJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"commonjs/index.js","types":"index.d.ts","es2015":"esm2015/index.js","module":"esm5/index.js","engines":{"node":">=7.0.0"},"private":false,"_npmUser":{"name":"akanass","email":"akanass@icloud.com"},"repository":{"url":"git+ssh://git@github.com/njl07/rx-socket-client.git","type":"git"},"_npmVersion":"5.6.0","description":"Reconnectable websocket client with RxJS Subject","directories":{},"_nodeVersion":"10.2.1","dependencies":{"websocket":"^1.0.26","@types/node":"^10.1.4"},"_hasShrinkwrap":false,"peerDependencies":{"rxjs":"^6.2.0"},"_npmOperationalInternal":{"tmp":"tmp/rx-socket-client_1.1.0_1527773437948_0.22982899473661544","host":"s3://npm-registry-packages"}},"1.2.0":{"name":"@akanass/rx-socket-client","version":"1.2.0","keywords":["RxJS","Rx","ReactiveX","Observable","Observer","Subject","Socket","WebSocket","Streams","Async","ES2015","ES2016","ES2017","ES6","ES7","ES8","Typescript","Browser"],"license":"SEE LICENSE IN https://github.com/akanass/rx-socket-client/blob/master/LICENSE.md","_id":"@akanass/rx-socket-client@1.2.0","maintainers":[{"name":"akanass","email":"akanass@icloud.com"}],"contributors":[{"url":"https://github.com/akanass","name":"Nicolas Jessel"}],"homepage":"https://github.com/akanass/rx-socket-client#readme","bugs":{"url":"https://github.com/akanass/rx-socket-client/issues"},"dist":{"shasum":"a678130f282354eb10a367976ead0dc6d4a5a0a5","tarball":"https://registry.npmjs.org/@akanass/rx-socket-client/-/rx-socket-client-1.2.0.tgz","fileCount":26,"integrity":"sha512-T03ZW7IN+9WOPzAQL7ozsM/IKNhTJJSf2kGje8Ad3Hcj+7VVCKf2KPRVGwDX28c92cqJvovTq7EeEdNUf7lEzg==","signatures":[{"sig":"MEQCIEfrb9DlDD+VTk0BMnaz+5or3+kjv3A6gY+CPbv2+hUSAiA2kngfN0t8RpFL0HB1BJsuiwZeGDSRrO+YbILE3elzKA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1161803,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdMGXuCRA9TVsSAnZWagAAO/UP/3wCOGPPZKT/gAvMnBJq\nSvTU6FXCH8sP/yGkTY8Gm/q8VxcVTZZp0JalmBpg+eFJiaun+aUrE5AljUMd\nLXBFiY7b7E4JnuKy2ZEBuiivJiJvtlEDD1MoTM0LWVPTJoSQtug2n0YNS6wU\no6j+2ggKk0K3U5G4svqOcWcnu1vHK+VQz/vc8/q3xtzv7eypCPKOsK5sI23y\njnJavCs41pqflnahF9khwHz00RsdfEG/OkM4DwjdxynnUuuYq1S188YCDg8Z\nTVKoTzCQDoo9np8OkDEx+fBpPphEIjPcW1zvD7F4jztZ1L9H9VxbXL59ks9E\nmBq7F2ZlIjVRqxUrvy41YXTHLjQsPEHXZCJ+5ByO99RoHrGTqxEl3vVAzoyR\nNKoNlve1pDGK8QzO7RK7i+0Z2WTCuxUtnGiDG6KG+0L5wnmFjs7sUOshqTJH\nzqe3NU2L7scbOFgZRocg7eNo7OU5HH2N6Ra/6NyIlxBPnAKUfVZmC/bnD5U7\nm9yCCILq/+O0M6B92pCnD5piRCG+ln5tOC20MMgAeusHHPqW6UI2tgCecH5+\nUATHIOGrGQutEzphgRTJ4w3E0jIEEe2oBIsDCHsiqELH8G9GoR7wjk0laspM\nKg/fmB0Dso2YBiy1OZtGS4t2E6G5usXDvdKsh7W9+4qDN5iOzH/TtLVdXiw5\n+jfu\r\n=Jerm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"commonjs/index.js","types":"index.d.ts","es2015":"esm2015/index.js","module":"esm5/index.js","engines":{"node":">=7.0.0"},"private":false,"_npmUser":{"name":"akanass","email":"akanass@icloud.com"},"repository":{"url":"git+ssh://git@github.com/akanass/rx-socket-client.git","type":"git"},"_npmVersion":"6.10.1","description":"Reconnectable websocket client with RxJS Subject","directories":{},"_nodeVersion":"12.6.0","dependencies":{"websocket":"^1.0.29","@types/node":"^12.6.8"},"_hasShrinkwrap":false,"peerDependencies":{"rxjs":"^6.5.2"},"_npmOperationalInternal":{"tmp":"tmp/rx-socket-client_1.2.0_1563452909619_0.6198625539124256","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"@akanass/rx-socket-client","version":"2.0.0","keywords":["RxJS","Rx","ReactiveX","Observable","Observer","Subject","Socket","WebSocket","Streams","Async","ES2015","ES2016","ES2017","ES6","ES7","ES8","Typescript","Browser"],"author":{"name":"Nicolas Jessel","email":"akanass@icloud.com"},"license":"MIT","_id":"@akanass/rx-socket-client@2.0.0","maintainers":[{"name":"akanass","email":"akanass@icloud.com"}],"homepage":"https://github.com/akanass/rx-socket-client#readme","bugs":{"url":"https://github.com/akanass/rx-socket-client/issues"},"dist":{"shasum":"5630e3ab3059aee0a6c1cdbf10f0d3e13d6682e6","tarball":"https://registry.npmjs.org/@akanass/rx-socket-client/-/rx-socket-client-2.0.0.tgz","fileCount":18,"integrity":"sha512-vJnwkZeEK6MP0QgdvQ/4GEafl+FLqjBy3u2JMLoEo9f05M2B+ZYe8p/fid6UpejO+vzzC6Vy88At/O5J3SBx8Q==","signatures":[{"sig":"MEUCIFZDqO0DBGoVOW9H+UU9+PEkjF/1bD13aIiDKDsPEOYMAiEA0pJuAYL/rkhQeLDErPM0WpLQGRcL0rMFTJiUIWe/hUM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":78101,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhQg4iCRA9TVsSAnZWagAAMl8QAI/8IX+KxTAvZTZca7TI\ngDPScD26zxuTY4pQbYoRsbSADliVIeWpdl4GQR73HGh+/Ks74VOkqIOE5o2B\n0t/3cQe06R/s1lyOUgAFdS7nkBgQMmlAo7ZomyT9L+ovS0ISC9ueKKyWCYy8\nBSeyFn0f1r3RZxWrU0BZBXnaLlfKb3wJ/KMfqTk6kmqqbkMQJsApFcmJdSZr\n2z+u8uNo1l9FTv6cwUL80lMqPBVYmBpqS0/zdbl62mm+xX1PKSowY943lRtO\nhCL/UJP7rtG8BKzKdjzvT15tg6Ryl9OnZMoqHP9tI0Fi5wpW4PGaqad6Q8Xm\nJvcCorzXqNmcwBflE8m8qRvAH2Qt1hZtshmVd/r/lZx0dkwfuj43921yjjW0\niMOUbpx2ynxUs5RHShntdk/f0jtjkrqOmWVsceUuxO0TACq6D6jFTMKIDbPi\nb0lE14862Emx/Dzkvx1/FDoyFZsidhxTi+MlU2Y+j7tKj6p02mG/ZrOTwl/H\nsVNgAeG+NR9wpABlOHb+7YiBhIyvtgWK+oI+3xUMP+IOB1+zzH8zVZJ4x53x\nw/WuUxH3i+jIwbTE2PXAsF/iFtFPHfrvPQ0xHMpWW78bfm32GkWRxASG0KAp\n/UYGdhLnKL/OuaqWo4KyTTjFJiU2titC2E1a6/xRzqt6rmEa6L7Oi184zXPG\nfQbg\r\n=5DAV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"commonjs/index.js","types":"index.d.ts","module":"esm2015/index.js","engines":{"node":">=7.0.0"},"gitHead":"002f4ec59b6b44ebb9298264e28e1dac614c9908","private":false,"_npmUser":{"name":"akanass","email":"akanass@icloud.com"},"repository":{"url":"git+ssh://git@github.com/akanass/rx-socket-client.git","type":"git"},"_npmVersion":"7.23.0","description":"Reconnectable websocket client with RxJS Subject","directories":{},"_nodeVersion":"16.9.1","dependencies":{"websocket":"^1.0.34","@types/node":"^16.9.1"},"_hasShrinkwrap":false,"peerDependencies":{"rxjs":"^7.3.0"},"_npmOperationalInternal":{"tmp":"tmp/rx-socket-client_2.0.0_1631718946689_0.4446689764750478","host":"s3://npm-registry-packages"}},"2.1.0":{"name":"@akanass/rx-socket-client","version":"2.1.0","description":"Reconnectable websocket client with RxJS Subject","main":"commonjs/index.js","module":"esm2015/index.js","types":"index.d.ts","private":false,"repository":{"type":"git","url":"git+ssh://git@github.com/akanass/rx-socket-client.git"},"keywords":["RxJS","Rx","ReactiveX","Observable","Observer","Subject","Socket","WebSocket","Streams","Async","ES2015","ES2016","ES2017","ES6","ES7","ES8","Typescript","Browser"],"author":{"name":"Nicolas Jessel","email":"akanass@icloud.com"},"license":"MIT","bugs":{"url":"https://github.com/akanass/rx-socket-client/issues"},"homepage":"https://github.com/akanass/rx-socket-client#readme","dependencies":{"@types/node":"^22.15.19","websocket":"^1.0.35"},"peerDependencies":{"rxjs":"^7.8.2"},"engines":{"node":">=16.0.0"},"packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e","_id":"@akanass/rx-socket-client@2.1.0","gitHead":"e3607a72c5473b9fffb83bb44000bc756d8bd1db","_nodeVersion":"24.0.2","_npmVersion":"11.3.0","dist":{"integrity":"sha512-+YlW90RfyUjHvoKCFeR0Q5aPPijW9ajDpqPQ1rnb1H5N9GAJ5uA4ynOtlsrH+wx+BPOEaZQ+o2wMt3vr1qsVbg==","shasum":"85b485b11be3179746cc99e793c68b34bd70549d","tarball":"https://registry.npmjs.org/@akanass/rx-socket-client/-/rx-socket-client-2.1.0.tgz","fileCount":18,"unpackedSize":78757,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCOnQvTM1LZUMNuO2qfQ0nz8Y4HE41EYVb2/TbdGBYprgIhAPFnu71IAMSPHmxI45A9Q7fxhBFOrkbMv3SwDnOMDrtv"}]},"_npmUser":{"name":"akanass","email":"akanass@icloud.com"},"directories":{},"maintainers":[{"name":"akanass","email":"akanass@icloud.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rx-socket-client_2.1.0_1747677271335_0.3030364043089917"},"_hasShrinkwrap":false}},"time":{"created":"2018-05-16T11:22:05.851Z","modified":"2025-05-19T17:54:31.711Z","1.0.0":"2018-05-16T11:22:06.396Z","1.1.0":"2018-05-31T13:30:38.118Z","1.2.0":"2019-07-18T12:28:29.802Z","2.0.0":"2021-09-15T15:15:46.811Z","2.1.0":"2025-05-19T17:54:31.524Z"},"bugs":{"url":"https://github.com/akanass/rx-socket-client/issues"},"author":{"name":"Nicolas Jessel","email":"akanass@icloud.com"},"license":"MIT","homepage":"https://github.com/akanass/rx-socket-client#readme","keywords":["RxJS","Rx","ReactiveX","Observable","Observer","Subject","Socket","WebSocket","Streams","Async","ES2015","ES2016","ES2017","ES6","ES7","ES8","Typescript","Browser"],"repository":{"type":"git","url":"git+ssh://git@github.com/akanass/rx-socket-client.git"},"description":"Reconnectable websocket client with RxJS Subject","maintainers":[{"name":"akanass","email":"akanass@icloud.com"}],"readme":"# Rx-Socket-Client\n\nReconnectable websocket client, [RxJS](http://reactivex.io/rxjs) compliant, wrote in full [Typescript](https://www.typescriptlang.org/docs/tutorial.html) | [ES6](https://babeljs.io/docs/learn-es2015/) for client and browser side.\n\nThis library is an **enhancement** of [RxJS WebSocketSubject](https://github.com/ReactiveX/rxjs/blob/master/src/internal/observable/dom/WebSocketSubject.ts) to add more features and the native support of **Node.js** environment.\n\n\n## Table of contents\n\n* [Installation](#installation)\n* [Super simple to use](#super-simple-to-use)\n* [API in Detail](#api-in-detail)\n    * [webSocket(urlConfigOrSource)](#websocketurlconfigorsource)\n    * [.connectionStatus$](#connectionstatus$)\n    * [.send(data)](#senddata)\n    * [.emit(event, data)](#emitevent-data)\n    * [.on(event, cb(data))](#onevent-cbdata)\n    * [.on$(event)](#onevent)\n    * [.onBytes(cb(data))](#onbytescbdata)\n    * [.onBytes$()](#onbytes)\n    * [.onClose$()](#onclose)\n* [RxSocketClientConfig in detail](#rxsocketclientconfig-in-detail)\n* [Contributing](#contributing)\n* [Change History](#change-history)\n* [License](#license)\n\n## Installation\n\n```sh\n$ yarn add @akanass/rx-socket-client rxjs\n\nor\n\n$ npm install --save @akanass/rx-socket-client rxjs\n```\n\n## Super simple to use\n\n**Rx-Socket-Client** is designed to be the simplest way possible to make web socket connections and calls.\n\nIt's fully `Typescript` | `ES6` written so you can import it :\n\n```typescript\nimport { webSocket } from '@akanass/rx-socket-client';\n```\n\nor use `CommonJS`:\n\n```javascript\nconst webSocket = require('@akanass/rx-socket-client').webSocket;\n```\n\nNow, it's easy to perform a `WS` calls:\n\n```typescript\nconst socket$ = webSocket('ws://127.0.0.1:1235');\n\n// send message\nsocket$.send('my message from socket');\n\n// emit message on specific event\nsocket$.emit('event', 'my message from socket for event');\n\n// receive message from server with callback\nsocket$.on('event', data => console.log(data)); // will display received data in console if event is fired\n\n// receive message from server with Observable\nsocket$.on$('event').subscribe(data => console.log(data)); // will display received data in console if event is fired\n```\n\n[Back to top](#table-of-contents)\n\n## API in Detail\n\n### `webSocket(urlConfigOrSource)`\n\nReturns an instance of `RxSocketClientSubject` with given configuration.\n\n**Parameter:**\n> ***{string | RxSocketClientConfig} urlConfigOrSource*** *(required): `url` or `RxSocketClientConfig` object with default values foreach next web socket calls*\n\n**Result:**\n> ***new*** *`RxSocketClientSubject` instance*\n\n### `.connectionStatus$`\n\nThis property provides an **Observable** to check server's connection status.\n\nFor example:\n\n```typescript\nconst socket$ = webSocket('ws://127.0.0.1:1235');\n\nsocket$.connectionStatus$.subscribe(isConnected => isConnected ? console.log('Server connected'): console.log('Server disconnected'));\n```\n\n### `.send(data)`\n\nThis method sends **data** to web socket server.\n\n**Parameter:**\n> ***{any} data*** *(required): data sent to web socket server. Can be of any type.*\n\n**Note:** If `data` is an **object**, it'll be **stringified** with `JSON.stringify`. If it's a **string** or a **buffer**, it'll be sent like this **without** transformation.\n\n**Note:** The message sent to server will be like this:\n\nFor **binary data**,\n\n```\n{\n  type: 'binary',\n  binaryData: `data`\n}\n```\n\nFor **others**,\n\n```\n{\n  type: 'utf8',\n  utf8Data: `data`\n}\n```\n\n### `.emit(event, data)`\n\nThis method emits **data** for given **event** to web socket server.\n\n**Parameters:**\n> - ***{string} event*** *(required): event sent to web socket server.*\n> - ***{any} data*** *(required): data sent to web socket server. Can be of any type.*\n\n**Note:** This method calls [`.send`](#senddata) method with **object** parameter `{event, data}`.\n\n### `.on(event, cb(data))`\n\nThis method handles **text response** for given **event** from web socket server.\n\n**Parameters:**\n> - ***{string | 'close'} event*** *(required): event represents value inside `{utf8Data.event}` or `{event}` from server response.*\n> - ***{function} cb*** *(required): cb is the function executed if event matches the response from the server. `data` in parameter is the **text** data received from the server.*\n\n**Note:** `close` event will be only fired by `Observable` **complete** process.\n\n**Note:** Message received from the server can be like this:\n\n**UTF** Text Message,\n\n```\n{\n  type: 'utf8',\n  utf8Data: {\n    event: `event`,\n    data: `data`\n  }\n}\n```\n\n**Simple** Text Message,\n\n```\n{\n  event: `event`,\n  data: `data`\n}\n```\n\nFor example:\n\n```typescript\nconst socket$ = webSocket('ws://127.0.0.1:1235');\n\n// receive message from server with callback\nsocket$.on('event', data => console.log(data)); // will display received data in console if event is fired\n\n// handle close from server with callback\nsocket$.on('close', () => console.log('Socket closed')); // will display message in console if event is fired\n```\n\n### `.on$(event)`\n\nThis method is the same as [`.on`](#onevent-cbdata) but with `Observable` result.\n\n**Parameter:**\n> ***{string} event*** *(required): event represents value inside `{utf8Data.event}` or `{event}` from server response.*\n\n**Result:**\n> *Observable instance*\n\n**Note:** `close` event is not supported with this method, check after for specific implementation. But, you can just use `complete` section of each **subscription** to handle them in each event if you want.\n\nFor example:\n\n```typescript\nconst socket$ = webSocket('ws://127.0.0.1:1235');\n\nsocket$.on$('event').subscribe(data => console.log(data)); // will log data from server in console if event is fired\n\n// handle close in subscription\nsocket$.on$('*').subscribe(undefined, undefined, () => console.log('Socket closed'));\n```\n\n### `.onBytes(cb(data))`\n\nThis method handles **binary response** from web socket server.\n\n**Parameter:**\n> ***{function} cb*** *(required): cb is the function executed with the response from the server. `data` in parameter is the **binary** data received from the server.*\n\n**Note:** Binary received from the server can be like this:\n\n**Bytes** Message,\n\n```\n{\n  type: 'binary',\n  binaryData: <Buffer 74 6f 74 6f>\n}\n```\n\n**Simple** Bytes Message,\n\n```\n<Buffer 74 6f 74 6f>\n```\n\nFor example:\n\n```typescript\nconst socket$ = webSocket('ws://127.0.0.1:1235');\n\nsocket$.onBytes(data => console.log(data)); // will log data from server in console if event is fired\n```\n\n### `.onBytes$()`\n\nThis method is the same as [`.onBytes`](#onbytescbdata) but with `Observable` result.\n\n**Result:**\n> *Observable instance*\n\n**Note:** `close` event is not supported with this method, check after for specific implementation. But, you can just use `complete` section of each **subscription** to handle them in each event if you want.\n\nFor example:\n\n```typescript\nconst socket$ = webSocket('ws://127.0.0.1:1235');\n\nsocket$.onBytes$().subscribe(data => console.log(data)); // will log data from server in console if event is fired\n\n// handle close in subscription\nsocket$.onBytes$().subscribe(undefined, undefined, () => console.log('Socket closed'));\n```\n\n### `.onClose$()`\n\nThis method handles `close` from web socket server with `Observable` result and send `complete` inside **`next`** process.\n\n**Result:**\n> *Observable instance*\n\nFor example:\n\n```typescript\nconst socket$ = webSocket('ws://127.0.0.1:1235');\n\nsocket$.onClose$().subscribe(() => console.log('Socket closed')); // will log close from server in console if event is fired\n```\n\n[Back to top](#table-of-contents)\n\n## `RxSocketClientConfig` in detail\n\n> - ***{string} url*** *(required): connection url to web socket server.*\n> - ***{string | Array<string>} protocol*** *(optional): the protocol to use to connect.*\n> - ***{'blob' | 'arraybuffer'} binaryType*** *(optional): sets the `binaryType` property of the underlying WebSocket.*\n> - ***{number} reconnectInterval*** *(optional): sets the reconnection interval value. (default: `5000 ms`).*\n> - ***{number} reconnectAttempts*** *(optional): sets the reconnection attempts value. (default: `10`).*\n> - ***{ { new(url: string, protocol?: string | Array<string>): WebSocket } } WebSocketCtor*** *(optional): a WebSocket constructor to use. This is useful for mocking a WebSocket for testing purposes.*\n\n[Back to top](#table-of-contents)\n\n## Contributing\n\nTo set up your development environment:\n\n1. clone the repo to your workspace,\n2. in the shell `cd` to the main folder,\n3. hit `npm or yarn install`,\n4. run `npm or yarn run test`.\n    * It will lint the code and execute all tests.\n    * The test coverage report can be viewed from `./coverage/lcov-report/index.html`.\n\n[Back to top](#table-of-contents)\n\n## Change History\n\n* v2.1.0 (2025-05-19)\n    * Upgrade all packages' versions to move on `rxjs:7.8.2` and delete incompatible packages\n    * Documentation\n    * Note: Integration tests have to be rewritten to be fully compliant - TBD\n* v2.0.0 (2021-09-15)\n    * Upgrade all packages' versions to move on `rxjs:7.3.0` and delete incompatible packages\n    * Delete browser single version due to incompatibility\n    * Delete `es5` version and now module is only on `es2015` and if you want an older support, your bundle system should transpile it to `es5`\n    * Documentation\n* v1.2.0 (2019-07-18)\n    * Upgrade all packages' versions\n    * Migrate tests to [jest](https://jestjs.io/en/) and [ts-jest](https://kulshekhar.github.io/ts-jest/)\n    * Documentation\n* v1.1.0 (2018-05-31)\n    * Delete `error` process/methods because never called with reconnection\n    * Update tests\n    * Latest packages' versions\n    * Documentation\n* v1.0.0 (2018-05-16)\n    * Carefully written from scratch to make `Rx-Socket-Client` a drop-in replacement for `WebSocketSubject`\n\n## License\n\nCopyright (c) 2018 **Nicolas Jessel** Licensed under the [MIT license](https://github.com/akanass/rx-socket-client/tree/master/LICENSE.md).\n\n[Back to top](#table-of-contents)\n","readmeFilename":"README.md"}