From aa89630f7c9f365266faf6ce3d44bccb8a2149a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Fri, 25 Jan 2013 15:58:43 +0100 Subject: [PATCH] added local ip address detection --- oscreceiver.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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);