2024-10-03 05:03:39 +00:00
|
|
|
# capacitor-sockets
|
|
|
|
|
|
|
|
Sockets
|
|
|
|
|
|
|
|
## Install
|
|
|
|
|
|
|
|
```bash
|
|
|
|
npm install capacitor-sockets
|
|
|
|
npx cap sync
|
|
|
|
```
|
|
|
|
|
|
|
|
## API
|
|
|
|
|
|
|
|
<docgen-index>
|
|
|
|
|
2024-10-03 17:45:22 +00:00
|
|
|
* [`create(...)`](#create)
|
|
|
|
* [`connect(...)`](#connect)
|
|
|
|
* [`send(...)`](#send)
|
|
|
|
* [`disconnect(...)`](#disconnect)
|
2024-10-03 17:55:00 +00:00
|
|
|
* [`close(...)`](#close)
|
2024-10-03 17:45:22 +00:00
|
|
|
* [`addListener('state', ...)`](#addlistenerstate-)
|
|
|
|
* [`addListener('message', ...)`](#addlistenermessage-)
|
|
|
|
* [Interfaces](#interfaces)
|
2024-10-03 05:03:39 +00:00
|
|
|
|
|
|
|
</docgen-index>
|
|
|
|
|
|
|
|
<docgen-api>
|
|
|
|
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
|
|
|
2024-10-03 17:45:22 +00:00
|
|
|
### create(...)
|
2024-10-03 05:03:39 +00:00
|
|
|
|
|
|
|
```typescript
|
2024-10-03 18:42:36 +00:00
|
|
|
create(options: { id: string; }) => Promise<void>
|
2024-10-03 05:03:39 +00:00
|
|
|
```
|
|
|
|
|
2024-10-03 18:42:36 +00:00
|
|
|
| Param | Type |
|
|
|
|
| ------------- | ---------------------------- |
|
|
|
|
| **`options`** | <code>{ id: string; }</code> |
|
2024-10-03 05:03:39 +00:00
|
|
|
|
2024-10-03 17:45:22 +00:00
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
|
|
### connect(...)
|
|
|
|
|
|
|
|
```typescript
|
2024-10-03 18:42:36 +00:00
|
|
|
connect(options: { id: string; host: string; port: number; useTLS?: boolean; acceptInvalidCertificates?: boolean; }) => Promise<void>
|
2024-10-03 17:45:22 +00:00
|
|
|
```
|
|
|
|
|
2024-10-03 18:42:36 +00:00
|
|
|
| Param | Type |
|
|
|
|
| ------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
|
|
| **`options`** | <code>{ id: string; host: string; port: number; useTLS?: boolean; acceptInvalidCertificates?: boolean; }</code> |
|
2024-10-03 17:45:22 +00:00
|
|
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
|
|
### send(...)
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
send(options: { id: string; message: string; }) => Promise<void>
|
|
|
|
```
|
|
|
|
|
|
|
|
| Param | Type |
|
|
|
|
| ------------- | --------------------------------------------- |
|
|
|
|
| **`options`** | <code>{ id: string; message: string; }</code> |
|
|
|
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
|
|
### disconnect(...)
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
disconnect(options: { id: string; }) => Promise<void>
|
|
|
|
```
|
|
|
|
|
|
|
|
| Param | Type |
|
|
|
|
| ------------- | ---------------------------- |
|
|
|
|
| **`options`** | <code>{ id: string; }</code> |
|
2024-10-03 05:03:39 +00:00
|
|
|
|
|
|
|
--------------------
|
|
|
|
|
2024-10-03 17:45:22 +00:00
|
|
|
|
2024-10-03 17:55:00 +00:00
|
|
|
### close(...)
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
close(options: { id: string; }) => Promise<void>
|
|
|
|
```
|
|
|
|
|
|
|
|
| Param | Type |
|
|
|
|
| ------------- | ---------------------------- |
|
|
|
|
| **`options`** | <code>{ id: string; }</code> |
|
|
|
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
2024-10-03 17:45:22 +00:00
|
|
|
### addListener('state', ...)
|
|
|
|
|
|
|
|
```typescript
|
2024-10-03 17:55:00 +00:00
|
|
|
addListener(eventName: "state", listenerFunc: (message: { id: string; state: string; }) => void) => Promise<PluginListenerHandle>
|
2024-10-03 17:45:22 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
| Param | Type |
|
|
|
|
| ------------------ | ----------------------------------------------------------------- |
|
|
|
|
| **`eventName`** | <code>'state'</code> |
|
|
|
|
| **`listenerFunc`** | <code>(message: { id: string; state: string; }) => void</code> |
|
|
|
|
|
|
|
|
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
|
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
|
|
### addListener('message', ...)
|
|
|
|
|
|
|
|
```typescript
|
2024-10-03 17:55:00 +00:00
|
|
|
addListener(eventName: "message", listenerFunc: (message: { id: string; message: string; }) => void) => Promise<PluginListenerHandle>
|
2024-10-03 17:45:22 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
| Param | Type |
|
|
|
|
| ------------------ | ------------------------------------------------------------------- |
|
|
|
|
| **`eventName`** | <code>'message'</code> |
|
|
|
|
| **`listenerFunc`** | <code>(message: { id: string; message: string; }) => void</code> |
|
|
|
|
|
|
|
|
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
|
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
|
|
### Interfaces
|
|
|
|
|
|
|
|
|
|
|
|
#### PluginListenerHandle
|
|
|
|
|
|
|
|
| Prop | Type |
|
|
|
|
| ------------ | ----------------------------------------- |
|
|
|
|
| **`remove`** | <code>() => Promise<void></code> |
|
|
|
|
|
2024-10-03 05:03:39 +00:00
|
|
|
</docgen-api>
|