From b001224bb95996fa59269a5c119c6a9f2047f288 Mon Sep 17 00:00:00 2001 From: Kyle K Date: Sun, 1 Jul 2012 21:57:24 -0500 Subject: start on prototype --- protoype/activeusers.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 protoype/activeusers.js (limited to 'protoype/activeusers.js') diff --git a/protoype/activeusers.js b/protoype/activeusers.js new file mode 100644 index 0000000..64df0d9 --- /dev/null +++ b/protoype/activeusers.js @@ -0,0 +1,44 @@ +/* + * activeusers.js + * + * list of active users, maps tag/user to a status string + */ + +var redis = require('redis'); +var client = redis.createClient(); +var util = require('util'); + +client.on('error', function(e) { + util.log('[activeusers] redis ' + e); +}); + +function isactive(tag) { + client.get(tag, function(err, reply) { + if (err || !reply) + return false; + else + return true; + }); +} + +function setstatus(tag, status) { + client.set(tag, status, redis.print); +} + +function list() { + client.keys('*', function(err, replies) { + if (err || !replies) + util.log('[activeusers] could not get a list of users'); + else + { + replies.forEach(function(reply, i) { + util.log('key ' + i + ': ' + reply); + }); + } + }); +} + +exports.isactive = isactive; +exports.setstatus = setstatus; +exports.list = list; + -- cgit v1.2.3