1.0.3 • Published 5 years ago

cordova-plugin-osc v1.0.3

Weekly downloads
5
License
Apache 2.0
Repository
github
Last release
5 years ago

cordova-plugin-osc

This is a very basic OSC plugin for Cordova, enabling sending and receiving OSC messages over a network.

WARNING: VERSION 1.x.x is a big rewrite and has a (slightly) new interface, please see below.

Supported platforms

  • android
  • ios
  • osx

Supported features

  • Sending and receiving OSC message over a network

OSC API

Methods

An OSC instance can both send and/or receive messages. Each instance can only listen one one local port, but can send to any remote port.

Each instance of an OSC object implements the following methods:

MethodDescriptionArguments
startListeningStart listening for OSC messages on given portport: Port to listen on [successCallback]: callback on success: function() [errorCallback]: callback on failure: function(err)
stopListeningStop listening for OSC messages[successCallback]: callback on success: function() [errorCallback]: callback on failure: function(err) some messages may still arrive after stopping due to internal threading
sendSend an OSC messagemessage: OSC message in the following format: {remoteAddress: 'IPorHOST', remotePort: PORT, address: '/path/of/message'[, arguments: [LIST, OF, ARGUMENTS]]} [successCallback]: callback on success: function() [errorCallback]: callback on failure: function(err)
addListenerAdds a listener for a certain OSC eventaddress: OSC address like /path/of/message successCallback: callback on received message: function(message) message format equals that of the send method [errorCallback]: callback on failure: function(err) It is possible to use wildcards in addresses (currently Android only)
onAlias of addListenersee addListener
closeCloses OSC object, removes all listeners and prepare it for garbage collection[successCallback]: callback on success: function() [errorCallback]: callback on failure: function(err)

Example

var port = 8000;

var osc = new OSC();

osc.startListening(port,
  function(){
    console.log('great success!')
  },
  function(err){
    console.log('epic fail', err)
  }
);

osc.on("/test", function(message){
  console.log('received a message');
  console.log(JSON.stringify(message));
});

osc.send({
    remoteAddress: '127.0.0.1',
    remotePort: 8001,
    address: '/test',
    arguments: [1, 2, 'three!']
});

Credits

Android OSC relies on (a heavily modified version of) JavaOSC

iOS OSC relies on (a heavily modified version of) CocoaOSC