0.0.4 • Published 7 months ago
cap-tcp-socket-plugin v0.0.4
cap-tcp-socket-plugin
A tcp socket plugin for capacitor
Install
npm install cap-tcp-socket-plugin
npx cap sync
API
sendAsync(...)
startReceiving(...)
stopReceiving()
addListener('receiveData', ...)
getCurrentIPAddress()
- Interfaces
- Enums
sendAsync(...)
sendAsync(options: { ipAddress: string; port: number; data: number[]; connectionTimeoutInSec: number; }) => Promise<{ status: ResultStatus; message?: string; data?: number[]; }>
Sends data over TCP to the specified IP address and port.
Param | Type | Description |
---|---|---|
options | { ipAddress: string; port: number; data: number[]; connectionTimeoutInSec: number; } | - Configuration for the TCP request. |
Returns: Promise<{ status: ResultStatus; message?: string; data?: number[]; }>
startReceiving(...)
startReceiving(options: { port: number; }) => Promise<void>
Param | Type |
---|---|
options | { port: number; } |
stopReceiving()
stopReceiving() => Promise<void>
addListener('receiveData', ...)
addListener(eventName: "receiveData", listener: (data: { status: string; data: number[]; }) => void) => Promise<PluginListenerHandle>
Adds a listener for the 'receiveData' event.
Param | Type | Description |
---|---|---|
eventName | 'receiveData' | - The name of the event (in this case, 'receiveData'). |
listener | (data: { status: string; data: number[]; }) => void | - The callback function to handle the event. |
Returns: Promise<PluginListenerHandle>
getCurrentIPAddress()
getCurrentIPAddress() => Promise<{ ipAddress: string; }>
Retrieves the current IP address of the device.
Returns: Promise<{ ipAddress: string; }>
Interfaces
PluginListenerHandle
Prop | Type |
---|---|
remove | () => Promise<void> |
Enums
ResultStatus
Members | Value |
---|---|
Unknown | 0 |
Success | 1 |
FailedToSendData | 2 |
NoResponseReceivedWithinTimeout | 3 |
FailedToReceiveData | 4 |