I'm currently building an application which should send messages via OSC protocol to Grasshopper (to Rhino 5).
I installed the OSC cordova plugin (https://github.com/sy1vain/cordova-osc-plugin) via cordova plugin add.
This all seems to work. The javascript class looks like this
OSCSender
var OSCSender = function(host, port){
this.host = host;
this.port = port;
}
OSCSender.prototype.send = function(address, data, successCallback, errorCallback){
if(typeof data == 'function'){
errorCallback = successCallback;
successCallback = data;
data = null;
}
if(typeof data == 'undefined' || data==null) data = [];
if(!(data instanceof Array)) data = [data];
//we prepend it so reverse order
data.unshift(address);
data.unshift(this.port);
data.unshift(this.host);
cordova.exec(successCallback, errorCallback, "OSC", "sendMessage", data);
}
OSCSender.prototype.close = function(successCallback){
cordova.exec(successCallback, function(err){
console.log(err);
}, "OSC", "closeSender", [this.host, this.port]);
}
module.exports = OSCSender;
I read in the documentation that you don't have do include this within tags so I didn't. When I did try it out I got the error modules not found.
The next thing I did was creating and instance within my index.js.
var osc = new OSCSender('test', 'test');
I received the error
Uncaught ReferenceError: OSCSender is not defined
Does anyone know how to solve this? There is no documentation for this plugin.