An open API service indexing awesome lists of open source software.

https://github.com/gee1k/capacitor-tcp-socket


https://github.com/gee1k/capacitor-tcp-socket

Last synced: 7 months ago
JSON representation

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 |