# capacitor-sockets
Sockets
## Install
```bash
npm install capacitor-sockets
npx cap sync
```
## API
* [`create(...)`](#create)
* [`connect(...)`](#connect)
* [`send(...)`](#send)
* [`disconnect(...)`](#disconnect)
* [`addListener('state', ...)`](#addlistenerstate-)
* [`addListener('message', ...)`](#addlistenermessage-)
* [Interfaces](#interfaces)
### create(...)
```typescript
create(options: { id: string; host: string; port: number; useTLS?: boolean; acceptInvalidCertificates?: boolean; }) => Promise
```
| Param | Type |
| ------------- | --------------------------------------------------------------------------------------------------------------- |
| **`options`** | { id: string; host: string; port: number; useTLS?: boolean; acceptInvalidCertificates?: boolean; }
|
--------------------
### connect(...)
```typescript
connect(options: { id: string; }) => Promise
```
| Param | Type |
| ------------- | ---------------------------- |
| **`options`** | { id: string; }
|
--------------------
### send(...)
```typescript
send(options: { id: string; message: string; }) => Promise
```
| Param | Type |
| ------------- | --------------------------------------------- |
| **`options`** | { id: string; message: string; }
|
--------------------
### disconnect(...)
```typescript
disconnect(options: { id: string; }) => Promise
```
| Param | Type |
| ------------- | ---------------------------- |
| **`options`** | { id: string; }
|
--------------------
### addListener('state', ...)
```typescript
addListener(eventName: 'state', listenerFunc: (message: { id: string; state: string; }) => void) => Promise
```
| Param | Type |
| ------------------ | ----------------------------------------------------------------- |
| **`eventName`** | 'state'
|
| **`listenerFunc`** | (message: { id: string; state: string; }) => void
|
**Returns:** Promise<PluginListenerHandle>
--------------------
### addListener('message', ...)
```typescript
addListener(eventName: 'message', listenerFunc: (message: { id: string; message: string; }) => void) => Promise
```
| Param | Type |
| ------------------ | ------------------------------------------------------------------- |
| **`eventName`** | 'message'
|
| **`listenerFunc`** | (message: { id: string; message: string; }) => void
|
**Returns:** Promise<PluginListenerHandle>
--------------------
### Interfaces
#### PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| **`remove`** | () => Promise<void>
|