diff rlgwebd.js @ 156:127f9e256d02

Keep a list of dgamelaunch games and put it in the /status message.
author John "Elwin" Edwards
date Tue, 01 Apr 2014 16:43:35 -0700
parents 245a2959f504
children e7f809f06c5c
line wrap: on
line diff
--- a/rlgwebd.js	Tue Apr 01 11:23:25 2014 -0700
+++ b/rlgwebd.js	Tue Apr 01 16:43:35 2014 -0700
@@ -65,6 +65,7 @@
 var logins = {};
 var sessions = {};
 var clients = {};
+var dglgames = {};
 var allowlogin = true;
 var nextsession = 0;
 var gamemux = new events.EventEmitter();
@@ -957,16 +958,20 @@
     var matchresult = fname.match(filere);
     if (!matchresult || matchresult[3])
       return;
-    gname = matchresult[1];
-    pname = matchresult[2];
+    var gname = matchresult[1];
+    var pname = matchresult[2];
+    var tag = gname + "/" + pname;
     if (chunk[0] == "E") {
       tslog("DGL: %s is playing %s: %s", pname, gname, fname)
+      dglgames[tag] = fname;
     }
     else if (chunk[0] == "C") {
       tslog("DGL: %s started playing %s: %s", pname, gname, fname)
+      dglgames[tag] = fname;
     }
     else if (chunk[0] == "D") {
       tslog("DGL: %s finished playing %s: %s", pname, gname, fname)
+      delete dglgames[tag];
     }
     else {
       tslog("Watcher says: %s", chunk)
@@ -1054,6 +1059,10 @@
     gamedesc["g"] = sessions[sessid].game.uname;
     statusinfo["g"].push(gamedesc);
   }
+  statusinfo["dgl"] = [];
+  for (var tag in dglgames) {
+    statusinfo["dgl"].push(tag);
+  }
   if (statusinfo.g.length == 0) {
     callback(statusinfo);
     return;