{"_id":"@ascentio/capacitor-socket-connection-plugin","name":"@ascentio/capacitor-socket-connection-plugin","dist-tags":{"latest":"8.0.0"},"versions":{"8.0.0":{"name":"@ascentio/capacitor-socket-connection-plugin","version":"8.0.0","description":"Capacitor Socket Connection Plugin","main":"dist/plugin.cjs.js","module":"dist/esm/index.js","types":"dist/esm/index.d.ts","unpkg":"dist/plugin.js","publishConfig":{"access":"public"},"author":{"name":"Maxim Zhemerenko"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/SpryRocks/capacitor-socket-connection-plugin.git"},"bugs":{"url":"https://github.com/SpryRocks/capacitor-socket-connection-plugin/issues"},"keywords":["capacitor","plugin","native"],"scripts":{"lint":"yarn run eslint","build":"npm run clean && tsc && rollup -c rollup.config.mjs","clean":"rimraf ./dist"},"dependencies":{"@capacitor/android":"^8.0.2","@spryrocks/logger-plugin":"^0.1.17-alpha.2"},"devDependencies":{"@capacitor/core":"^8.0.2","@spryrocks/eslint-config":"^0.4.0-alpha.0","rimraf":"^6.0.1","rollup":"^4.52.5","typescript":"^5.9.3"},"peerDependencies":{"@capacitor/core":"^8.0.2"},"capacitor":{"ios":{"src":"ios"},"android":{"src":"android"}},"packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e","gitHead":"16c213d69b4ba279d9c261c8b3dbf3e7aa8d9cea","_id":"@ascentio/capacitor-socket-connection-plugin@8.0.0","homepage":"https://github.com/SpryRocks/capacitor-socket-connection-plugin#readme","_nodeVersion":"24.11.1","_npmVersion":"11.8.0","dist":{"integrity":"sha512-w8YwG3i0gVJ90Vl/zHYIba2iZMMdkToFt1Lo9V9fFgNLwgYhDWp1WlVTxpwMPOc0YjagbIMYF8QCTtHp16McIg==","shasum":"4fe26615de13867a56b198d40fa0512392dac3df","tarball":"https://registry.npmjs.org/@ascentio/capacitor-socket-connection-plugin/-/capacitor-socket-connection-plugin-8.0.0.tgz","fileCount":61,"unpackedSize":116083,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCp2fjEnuDJlxzlyq0PVvNYj+3siB7bepyIjx0XDyZWuwIgXBRCFDVOoX6xhrFxBhBtcSn85xmp10NmS8808nTqaxY="}]},"_npmUser":{"name":"daanvanhulst","email":"daan.van.hulst@ascentio.nl"},"directories":{},"maintainers":[{"name":"daanvanhulst","email":"daan.van.hulst@ascentio.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/capacitor-socket-connection-plugin_8.0.0_1770033206926_0.8548177250512934"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-02T11:53:26.819Z","8.0.0":"2026-02-02T11:53:27.065Z","modified":"2026-02-02T11:53:27.306Z"},"maintainers":[{"name":"daanvanhulst","email":"daan.van.hulst@ascentio.nl"}],"description":"Capacitor Socket Connection Plugin","homepage":"https://github.com/SpryRocks/capacitor-socket-connection-plugin#readme","keywords":["capacitor","plugin","native"],"repository":{"type":"git","url":"git+https://github.com/SpryRocks/capacitor-socket-connection-plugin.git"},"author":{"name":"Maxim Zhemerenko"},"bugs":{"url":"https://github.com/SpryRocks/capacitor-socket-connection-plugin/issues"},"license":"MIT","readme":"# @spryrocks/capacitor-socket-connection-plugin\n\nCapacitor Socket Connection Plugin\n\n## Install\n\n```bash\nnpm install @spryrocks/capacitor-socket-connection-plugin@8.0.0\n```\n\nsee [main-capacitor5](https://github.com/SpryRocks/capacitor-socket-connection-plugin/tree/main-capacitor5) branch for capacitor 5\n\nsee [main-capacitor2](https://github.com/SpryRocks/capacitor-socket-connection-plugin/tree/main-capacitor2) branch for capacitor 2\n\n## Usage\n\n### Create instance of socket connection class\n\n```typescript\nconst socket = new Socket();\n```\n\n### Bind to events\n\n#### onData\n\n```typescript\nsocket.onData = function(data) {\n  // handle received data\n};\n```\n\n##### Callback function parameters\n\n\n| Name | Type       |\n| ---- | ---------- |\n| data | Uint8Array |\n\n#### onClose\n\n```typescript\nsocket.onClose = function() {\n    // handle socket close\n};\n```\n\n#### onError\n\n```typescript\nsocket.onError = function(error) {\n    // handle socket error\n};\n```\n\n##### Callback function parameters\n\n\n| Name  | Type    |\n| ----- | ------- |\n| error | unknown |\n\n#### onStateChanges\n\n```typescript\nsocket.onStateChanged = function(state) {\n    // handle socket state change\n};\n```\n\n##### Callback function parameters\n\n\n| Name  | Type        |\n| ----- | ----------- |\n| state | SocketState |\n\n### Connect socket to endpoint\n\n```typescript\nawait socket.open(host, port);\n```\n\n#### Parameters\n\n\n| Name | Type   |\n| ---- | ------ |\n| host | String |\n| port | Number |\n\n### Write data to socket\n\n```typescript\nawait socket.write(data);\n```\n\n#### Parameters\n\n\n| Name | Type       |\n| ---- | ---------- |\n| data | Uint8Array |\n\n### Close socket connection\n\n```typescript\nawait socket.close();\n```\n\n### Get current state\n\n```typescript\nconst state = socket.state;\n```\n\n## Q&A\n\nQ: When I call the open method after being disconnected, I will be prompted that the open method can only be called once. How should I reconnect?\n\nA: To re-connect the socket you should create the new socket and then open it.\n\n## Contributors\n\n* Thanks [@JEreth](https://github.com/JEreth) for fix gradle config by adding missing settings and dependencies [#22](https://github.com/SpryRocks/capacitor-socket-connection-plugin/pull/22)\n* Thanks [@dreadnought](https://github.com/dreadnought) for update the plugin to Capacitor 6 [#28](https://github.com/SpryRocks/capacitor-socket-connection-plugin/pull/28)\n* Thanks [@daanvanhulst](https://github.com/daanvanhulst) for updating the plugin to Capacitor 7 [#43]\n","readmeFilename":"README.md","_rev":"1-dff494de81691c6ca3c48abc5b254106"}