cordova-plugin-advanced-websocket-types
v0.0.5
Published
Types of cordova-plugin-advanced-websocket for Typescript/Ionic/Angular
Downloads
215
Maintainers
Readme
cordova-plugin-advanced-websocket-types
Typescript additional types package for the cordova plugin cordova-plugin-advanced-websocket
Installation
ionic cordova plugin add cordova-plugin-advanced-websocket
npm i --save-dev cordova-plugin-advanced-websocket-types
Typescript / Ionic Example
import {
CordovaWebsocketOptions
} from 'cordova-plugin-advanced-websocket-types';
const wsOptions: CordovaWebsocketOptions = {
url: 'wss://echo.websocket.org',
timeout: 5000,
pingInterval: 10000,
headers: {Authorization: `Bearer ${accessToken}`},
acceptAllCerts: false
};
window.CordovaWebsocketPlugin.wsConnect(
wsOptions,
event => { // CordovaWebsocketEvent
console.log(`Received callback from WebSocket: ${event?.callbackMethod}`);
},
success => { // CordovaWebsocketSuccess
console.log(`Connected to WebSocket with id: ${success.webSocketId}`);
},
error => { // CordovaWebsocketError
console.log(`Failed to connect to WebSocket: code: ${error?.code}, reason: ${error?.reason}`, error?.exception);
}
);