Skip to content

Pragmatic-Apps/capacitor-socket-connection-plugin

 
 

Repository files navigation

@spryrocks/capacitor-socket-connection-plugin

Capacitor Socket Connection Plugin

Install

npm install @spryrocks/[email protected]

see main-capacitor2 branch for capacitor 2

Usage

Create instance of socket connection class

const socket = new Socket();

Bind to events

onData

socket.onData = function(data) {
  // handle received data
};
Callback function parameters
Name Type
data Uint8Array

onClose

socket.onClose = function() {
    // handle socket close
};

onError

socket.onError = function(error) {
    // handle socket error
};
Callback function parameters
Name Type
error unknown

Connect socket to endpoint

await socket.open(host, port);

Parameters

Name Type
host String
port Number

Write data to socket

await socket.write(data);

Parameters

Name Type
data Uint8Array

Close socket connection

await socket.close();

About

Capacitor socket connection plugin

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 36.0%
  • Kotlin 33.2%
  • TypeScript 27.0%
  • Ruby 1.5%
  • JavaScript 1.3%
  • Objective-C 1.0%