From: Darren Date: Sun, 28 Aug 2011 17:28:08 +0000 (+0100) Subject: STDIN included in recoding X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=87a6abbe73a6d042f754d1ef2b5ead0f55ad2c50;p=KiwiIRC.git STDIN included in recoding --- diff --git a/node/app.js b/node/app.js index 47857c2..c7c5ee3 100644 --- a/node/app.js +++ b/node/app.js @@ -797,37 +797,42 @@ this.rehash = function () { /* * KiwiIRC controlling via STDIN */ -this.startControll = function () { - process.stdin.resume(); - process.stdin.on('data', function (chunk) { - var parts = chunk.toString().trim().split(' '); - switch (parts[0]) { - case 'rehash': - console.log('Rehashing...'); - console.log(kiwi.rehash() ? 'Rehash complete' : 'Rehash failed'); - break; - - case 'recode': - console.log('Recoding...'); - console.log(kiwi.recode() ? 'Recode complete' : 'Recode failed'); - break; - - case 'mod': - if (parts[1] === 'reload') { - console.log('Reloading module (' + parts[2] + ')..'); - kiwi.kiwi_mod.reloadModule(parts[2]); - } - break; +this.manageControll = function (data) { + var parts = data.toString().trim().split(' '); + switch (parts[0]) { + case 'rehash': + console.log('Rehashing...'); + console.log(kiwi.rehash() ? 'Rehash complete' : 'Rehash failed'); + break; + + case 'recode': + console.log('Recoding...'); + console.log(kiwi.recode() ? 'Recode complete' : 'Recode failed'); + break; + + case 'mod': + if (parts[1] === 'reload') { + console.log('Reloading module (' + parts[2] + ')..'); + kiwi.kiwi_mod.reloadModule(parts[2]); + } + break; - case 'cache': - if (parts[1] === 'clear') { - kiwi.cache.html = {}; - console.log('HTML cache cleared'); - } - break; + case 'cache': + if (parts[1] === 'clear') { + kiwi.cache.html = {}; + console.log('HTML cache cleared'); + } + break; + + case 'status': + var connections_cnt = 0; + for (var i in kiwi.connections) { + connections_cnt = connections_cnt + parseInt(kiwi.connections[i].count, 10); + } + console.log(connections_cnt.toString() + ' connected clients'); + break; - default: - console.log('Unknown command \'' + parts[0] + '\''); - } - }); + default: + console.log('Unknown command \'' + parts[0] + '\''); + } }; \ No newline at end of file diff --git a/node/kiwi.js b/node/kiwi.js index 189301f..e58607c 100644 --- a/node/kiwi.js +++ b/node/kiwi.js @@ -205,7 +205,9 @@ this.websocketListen(this.config.port, this.config.bind_address, this.httpHandle app.changeUser(); // Listen for controll messages -app.startControll(); +process.stdin.resume(); +process.stdin.on('data', function (data) { app.manageControll(data); }); +