added local ip address detection

This commit is contained in:
Lucas Pleß 2013-01-25 15:58:43 +01:00
parent fd8f36768c
commit aa89630f7c
1 changed files with 10 additions and 3 deletions

View File

@ -1,20 +1,27 @@
// this is a simple osc receiver for displaying osc messages on screen
// to use, simply start with "node oscreceiver.js <hubAddress> <hubPort>"
var readline = require('readline'); var readline = require('readline');
var dateFormat = require('dateformat'); var dateFormat = require('dateformat');
var osc = require('node-osc'); var osc = require('node-osc');
var listenPort = 8000; var listenPort = 8000;
var hubAddress = '192.168.23.43'; var hubAddress = process.argv.length > 2 ? process.argv[2] : '192.168.23.43';
var hubPort = 7110; var hubPort = process.argv.length > 3 ? process.argv[3] : 7110;
var oscClient = new osc.Client(hubAddress, hubPort); var oscClient = new osc.Client(hubAddress, hubPort);
var oscServer = new osc.Server(listenPort, '0.0.0.0'); 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) { oscServer.on("message", function (msg, rinfo) {
var dateString = dateFormat(new Date(), "HH:MM:ss.L"); var dateString = dateFormat(new Date(), "HH:MM:ss.L");
console.log(dateString + "\t" + msg); console.log(dateString + "\t" + msg);
}); });
oscClient.send('/subscribe','192.168.23.102', listenPort, "sekret");
var rl = readline.createInterface(process.stdin,process.stdout,null); var rl = readline.createInterface(process.stdin,process.stdout,null);