chaosc-fetcher/oscreceiver.js

32 lines
847 B
JavaScript
Raw Normal View History

2012-12-18 15:21:46 +00:00
var readline = require('readline');
2012-12-17 13:58:03 +00:00
var osc = require('node-osc');
var port = process.argv.length > 2 ? process.argv[2] : '5001';
2012-12-18 15:21:46 +00:00
var oscClient = new osc.Client('shell.ctdo.de',7110);
2012-12-17 13:58:03 +00:00
var oscServer = new osc.Server(port, '0.0.0.0');
2012-12-18 15:21:46 +00:00
2012-12-17 13:58:03 +00:00
oscServer.on("message", function (msg, rinfo) {
console.log("message: " + msg);
});
2012-12-18 15:21:46 +00:00
oscClient.send('/subscribe',"distinto.lp-server.net:"+port);
var rl = readline.createInterface(process.stdin,process.stdout,null);
rl.on('line', function(cmd) {
var sepIndex = cmd.indexOf(":");
if(sepIndex > 0) {
var path = cmd.substr(0, sepIndex);
var val = cmd.substr(sepIndex+1);
console.log("writing: %s with %s", path, val);
oscClient.send(path, val);
}
});
rl.on('close', function(cmd) {
console.log("bye bye");
oscClient.send('/unsubscribe',"distinto.lp-server.net:"+port);
process.exit(0);
});