I have a problem finishing a cordova wrapper for my ionic project.
I’m trying to create a ionic native wrapper for the following cordova plugin: https://github.com/becvert/cordova-plugin-websocket-server
I used the docs of the ionic native github project to get this done: https://github.com/ionic-team/ionic-native/blob/master/DEVELOPER.md
The getInterfaces function already works so far.
The vanilla example from the cordova plugin doc:
wsserver.getInterfaces(function (result) {
console.log(result)
});
my current ionic native wrapper for this looks like this:
@Cordova() getInterfaces(): Promise < any > { return; }
and I can use it in my project in this way:
this.webSocketServer.getInterfaces().then((result) => {
console.log(result);
}).catch(() => {
// Error!
});
But I got some trouble creating a more extended version of the wrapper for the start function, here are another example of the vanilla version:
this.wsserver.start(3001, {
onStart: function (addr, port) {
},
// WebSocket Server handlers
'onFailure': function (addr, port, reason) {
console.log('Stopped listening on %s:%d. Reason: %s', addr, port, reason);
},
// WebSocket Connection handlers
'onOpen': function (conn) {
console.log('A user connected from %s', conn.remoteAddr);
},
// WebSocket Message handlers
'onMessage': function (conn, msg) {
console.log(conn, msg);
}
});
So that’s my problem I’m a little bit lost on both things:
- creating the ionic native wrapper for the start function using the docs @ https://github.com/ionic-team/ionic-native/blob/master/DEVELOPER.md
- and then how’s the correct syntax to use it in my project
any help is really appreciated thanks in advance!
Mischa