npm package: @lidoravitan/capacitor-web-socket-server
Description: capacitor websocket server plugin
Author: Lidor Avitan
Latest version: 1.0.0

# @lidor/capacitor-web-socket-server

capacitor websocket server plugin

## Install

```bash
npm install @lidor/capacitor-web-socket-server
npx cap sync
```

## API

<docgen-index>

* [`connect(...)`](#connect)
* [`disconnect()`](#disconnect)
* [`send(...)`](#send)
* [`removeListeners()`](#removelisteners)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)
* [Enums](#enums)

</docgen-index>

<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

### connect(...)

```typescript
connect(options: ConnectOptions) => Promise<void>
```

| Param         | Type                                                      |
| ------------- | --------------------------------------------------------- |
| **`options`** | <code><a href="#connectoptions">ConnectOptions</a></code> |

--------------------


### disconnect()

```typescript
disconnect() => Promise<void>
```

--------------------


### send(...)

```typescript
send(options: SendOptions) => Promise<void>
```

| Param         | Type                                                |
| ------------- | --------------------------------------------------- |
| **`options`** | <code><a href="#sendoptions">SendOptions</a></code> |

--------------------


### removeListeners()

```typescript
removeListeners() => Promise<void>
```

--------------------


### Interfaces


#### ConnectOptions

| Prop       | Type                |
| ---------- | ------------------- |
| **`port`** | <code>number</code> |


#### SendOptions

| Prop           | Type                |
| -------------- | ------------------- |
| **`clientId`** | <code>string</code> |
| **`message`**  | <code>string</code> |


#### PluginListenerHandle

| Prop         | Type                                      |
| ------------ | ----------------------------------------- |
| **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |


### Type Aliases


#### AddListenerOverloads

<code>{ (eventName: <a href="#websocketserverevent">WebSocketServerEvent.SERVER_START</a>, cb: () =&gt; void): T; (eventName: <a href="#websocketserverevent">WebSocketServerEvent.SERVER_STOP</a>, cb: () =&gt; void): T; (eventName: <a href="#websocketserverevent">WebSocketServerEvent.CLIENT_CONNECT</a>, cb: (data: { clientId: string }) =&gt; void): T; (eventName: <a href="#websocketserverevent">WebSocketServerEvent.CLIENT_DISCONNECT</a>, cb: (data: { clientId: string }) =&gt; void): T; (eventName: <a href="#websocketserverevent">WebSocketServerEvent.MESSAGE</a>, cb: (data: { clientId: string; message: string }) =&gt; void): T; (eventName: <a href="#websocketserverevent">WebSocketServerEvent.ERROR</a>, cb: (data: { error: string }) =&gt; void): T; }</code>


### Enums


#### WebSocketServerEvent

| Members                 | Value                           |
| ----------------------- | ------------------------------- |
| **`SERVER_START`**      | <code>'serverStart'</code>      |
| **`SERVER_STOP`**       | <code>'serverStop'</code>       |
| **`CLIENT_CONNECT`**    | <code>'clientConnect'</code>    |
| **`CLIENT_DISCONNECT`** | <code>'clientDisconnect'</code> |
| **`MESSAGE`**           | <code>'message'</code>          |
| **`ERROR`**             | <code>'error'</code>            |

</docgen-api>