capacitor-sockets/README.md

123 lines
3.4 KiB
Markdown
Raw Normal View History

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)
* [`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 17:45:22 +00:00
create(options: { id: string; host: string; port: number; useTLS?: boolean; acceptInvalidCertificates?: boolean; }) => Promise<void>
2024-10-03 05:03:39 +00:00
```
2024-10-03 17:45:22 +00:00
| Param | Type |
| ------------- | --------------------------------------------------------------------------------------------------------------- |
| **`options`** | <code>{ id: string; host: string; port: number; useTLS?: boolean; acceptInvalidCertificates?: boolean; }</code> |
2024-10-03 05:03:39 +00:00
2024-10-03 17:45:22 +00:00
--------------------
### connect(...)
```typescript
connect(options: { id: string; }) => Promise<void>
```
| Param | Type |
| ------------- | ---------------------------- |
| **`options`** | <code>{ id: string; }</code> |
--------------------
### 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
### addListener('state', ...)
```typescript
addListener(eventName: 'state', listenerFunc: (message: { id: string; state: string; }) => void) => Promise<PluginListenerHandle>
```
| Param | Type |
| ------------------ | ----------------------------------------------------------------- |
| **`eventName`** | <code>'state'</code> |
| **`listenerFunc`** | <code>(message: { id: string; state: string; }) =&gt; void</code> |
**Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
--------------------
### addListener('message', ...)
```typescript
addListener(eventName: 'message', listenerFunc: (message: { id: string; message: string; }) => void) => Promise<PluginListenerHandle>
```
| Param | Type |
| ------------------ | ------------------------------------------------------------------- |
| **`eventName`** | <code>'message'</code> |
| **`listenerFunc`** | <code>(message: { id: string; message: string; }) =&gt; void</code> |
**Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
--------------------
### Interfaces
#### PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
2024-10-03 05:03:39 +00:00
</docgen-api>