chaosc-fetcher/oscreceiver.js

32 lines
847 B
JavaScript

var readline = require('readline');
var osc = require('node-osc');
var port = process.argv.length > 2 ? process.argv[2] : '5001';
var oscClient = new osc.Client('shell.ctdo.de',7110);
var oscServer = new osc.Server(port, '0.0.0.0');
oscServer.on("message", function (msg, rinfo) {
console.log("message: " + msg);
});
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);
});