capacitor-sockets/README.md

137 lines
3.7 KiB
Markdown
Raw Permalink 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)
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; }) =&gt; void</code> |
**Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</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; }) =&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>