summaryrefslogtreecommitdiffstats
path: root/protoype/activeusers.js
diff options
context:
space:
mode:
authorKyle K <kylek389@gmail.com>2012-07-01 21:57:24 -0500
committerKyle Kaminski <kyle@kkaminsk.com>2012-07-01 21:57:24 -0500
commitb001224bb95996fa59269a5c119c6a9f2047f288 (patch)
tree2fc3b73f4fedb63f6ce9a0cc02ec35ef0864ceab /protoype/activeusers.js
parent41946c6982647abec5d64b04323a081c73c43577 (diff)
downloadfubar-b001224bb95996fa59269a5c119c6a9f2047f288.tar.gz
fubar-b001224bb95996fa59269a5c119c6a9f2047f288.tar.bz2
fubar-b001224bb95996fa59269a5c119c6a9f2047f288.zip
start on prototype
Diffstat (limited to 'protoype/activeusers.js')
-rw-r--r--protoype/activeusers.js44
1 files changed, 44 insertions, 0 deletions
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;
+