From cfe4fa0bb9aa5d236483b8a009b9d2c023877fe6 Mon Sep 17 00:00:00 2001 From: Lucas Date: Tue, 18 Dec 2012 16:21:46 +0100 Subject: [PATCH] implemented hub registration --- cosmfetcher.js | 11 ++++++----- oscreceiver.js | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/cosmfetcher.js b/cosmfetcher.js index 17081e3..5d81c38 100644 --- a/cosmfetcher.js +++ b/cosmfetcher.js @@ -4,7 +4,7 @@ var osc = require('node-osc'); var streams = [ 91755, 70632 ]; -var oscclient = new osc.Client('127.0.0.1',5001); +var oscclient = new osc.Client('shell.ctdo.de',7110); var client = restify.createJsonClient({ url: 'http://api.cosm.com', @@ -19,18 +19,19 @@ var fubs = function() { } var getstream = function(streamId) { - client.get('/v2/feeds/' + streamId, function(err, req, res, obj) { - assert.ifError(err); + client.get('/v2/feeds/' + streamId + ".json", function(err, req, res, obj) { - if(obj.datastreams != null) { + if(err == null && obj.datastreams != null) { for(var i=0;i 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); +}); +