https://github.com/gee1k/capacitor-tcp-socket
https://github.com/gee1k/capacitor-tcp-socket
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/gee1k/capacitor-tcp-socket
- Owner: gee1k
- License: mit
- Created: 2024-02-21T13:53:06.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-20T16:05:56.000Z (over 1 year ago)
- Last Synced: 2025-03-26T08:02:27.420Z (10 months ago)
- Language: Java
- Size: 126 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# capacitor-tcp-socket
A TCP Socket Plugin for capacitor
Thanks [@ottimis](https://www.npmjs.com/package/@ottimis/tcp-socket)
## Install
```bash
npm install capacitor-tcp-socket
npx cap sync
```
## API
* [`connect(...)`](#connect)
* [`send(...)`](#send)
* [`read(...)`](#read)
* [`disconnect(...)`](#disconnect)
* [Interfaces](#interfaces)
### connect(...)
```typescript
connect(options: ConnectOptions) => Promise
```
| Param | Type |
| ------------- | --------------------------------------------------------- |
| **`options`** | ConnectOptions |
**Returns:** Promise<ConnectResult>
--------------------
### send(...)
```typescript
send(options: SendOptions) => Promise
```
| Param | Type |
| ------------- | --------------------------------------------------- |
| **`options`** | SendOptions |
--------------------
### read(...)
```typescript
read(options: ReadOptions) => Promise
```
| Param | Type |
| ------------- | --------------------------------------------------- |
| **`options`** | ReadOptions |
**Returns:** Promise<ReadResult>
--------------------
### disconnect(...)
```typescript
disconnect(options: DisconnectOptions) => Promise
```
| Param | Type |
| ------------- | --------------------------------------------------------------- |
| **`options`** | DisconnectOptions |
**Returns:** Promise<DisconnectResult>
--------------------
### Interfaces
#### ConnectResult
| Prop | Type |
| ------------ | ------------------- |
| **`client`** | number |
#### ConnectOptions
| Prop | Type |
| --------------- | ------------------- |
| **`ipAddress`** | string |
| **`port`** | number |
#### SendOptions
| Prop | Type |
| ------------ | ------------------- |
| **`client`** | number |
| **`data`** | string |
#### ReadResult
| Prop | Type |
| ------------ | ------------------- |
| **`result`** | string |
#### ReadOptions
| Prop | Type | Description |
| --------------- | ------------------- | ---------------------------------------------------------- |
| **`client`** | number | |
| **`expectLen`** | number | |
| **`timeout`** | number | timeout in seconds. default: 10 only ios supports timeout. |
#### DisconnectResult
| Prop | Type |
| ------------ | ------------------- |
| **`client`** | number |
#### DisconnectOptions
| Prop | Type |
| ------------ | ------------------- |
| **`client`** | number |