Use the following code to make plugin javascript
Here connectwebsocketserver is the function which called by javascript (index.js). If your plugin javascript file name is test then by following lin you can call this function
test.connectwebsocketserver("192.168.3.82",connectionsucess,conectionfail);
.. WebSocketServer is the name of objective C file plugin and startWebSocketServer is name of function in that file which will called from javascript. serverip is the parameter passing to the plugin function.
module.exports = {
connectwebsocketserver: function (serverip, successCallback, errorCallback) {
cordova.exec(function(){return successCallback},errorCallback,
// Define what class to route messages to
'WebSocketServer',
// Execute this method on the above class
'startWebSocketServer',
// An array containing one String (our newly created Date String).
[serverip]);
},
sendmessage: function(message, successCallback, errorCallback)
{
cordova.exec(successCallback,errorCallback,
// Define what class to route messages to
'WebSocketServer',
// Execute this method on the above class
'sendMessagetoAllConnectedWebSockets',
// An array containing one String (our newly created Date String).
[message]);
}
};
In the same way , you can call another plugin method sendMessagetoAllConnectedWebSockets
0 Comment(s)