Capacitor Socket Connection Plugin
npm install @spryrocks/[email protected]
see main-capacitor2 branch for capacitor 2
const socket = new Socket();
socket.onData = function(data) {
// handle received data
};
Name | Type |
---|---|
data | Uint8Array |
socket.onClose = function() {
// handle socket close
};
socket.onError = function(error) {
// handle socket error
};
Name | Type |
---|---|
error | unknown |
await socket.open(host, port);
Name | Type |
---|---|
host | String |
port | Number |
await socket.write(data);
Name | Type |
---|---|
data | Uint8Array |
await socket.close();