diff --git a/oscreceiver.js b/oscreceiver.js index dabc426..73e03a0 100644 --- a/oscreceiver.js +++ b/oscreceiver.js @@ -1,20 +1,27 @@ +// this is a simple osc receiver for displaying osc messages on screen +// to use, simply start with "node oscreceiver.js " + var readline = require('readline'); var dateFormat = require('dateformat'); var osc = require('node-osc'); var listenPort = 8000; -var hubAddress = '192.168.23.43'; -var hubPort = 7110; +var hubAddress = process.argv.length > 2 ? process.argv[2] : '192.168.23.43'; +var hubPort = process.argv.length > 3 ? process.argv[3] : 7110; var oscClient = new osc.Client(hubAddress, hubPort); var oscServer = new osc.Server(listenPort, '0.0.0.0'); +require('dns').lookup(require('os').hostname(), function (err, add, fam) { + console.log('my address: '+add + ' subscribing on hub ' + hubAddress); + oscClient.send('/subscribe', add, listenPort, "sekret"); +}); + oscServer.on("message", function (msg, rinfo) { var dateString = dateFormat(new Date(), "HH:MM:ss.L"); console.log(dateString + "\t" + msg); }); -oscClient.send('/subscribe','192.168.23.102', listenPort, "sekret"); var rl = readline.createInterface(process.stdin,process.stdout,null);