Mercurial > hg > rlgwebd
comparison 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 |
comparison
equal
deleted
inserted
replaced
155:245a2959f504 | 156:127f9e256d02 |
---|---|
63 | 63 |
64 /* Global state */ | 64 /* Global state */ |
65 var logins = {}; | 65 var logins = {}; |
66 var sessions = {}; | 66 var sessions = {}; |
67 var clients = {}; | 67 var clients = {}; |
68 var dglgames = {}; | |
68 var allowlogin = true; | 69 var allowlogin = true; |
69 var nextsession = 0; | 70 var nextsession = 0; |
70 var gamemux = new events.EventEmitter(); | 71 var gamemux = new events.EventEmitter(); |
71 | 72 |
72 /* Constructor. A TermSession handles a pty and the game running on it. | 73 /* Constructor. A TermSession handles a pty and the game running on it. |
955 var fname = chunk.slice(2, -1); | 956 var fname = chunk.slice(2, -1); |
956 var filere = /.*\/([^\/]*)\/([^\/:]*):(node:)?(.*)/; | 957 var filere = /.*\/([^\/]*)\/([^\/:]*):(node:)?(.*)/; |
957 var matchresult = fname.match(filere); | 958 var matchresult = fname.match(filere); |
958 if (!matchresult || matchresult[3]) | 959 if (!matchresult || matchresult[3]) |
959 return; | 960 return; |
960 gname = matchresult[1]; | 961 var gname = matchresult[1]; |
961 pname = matchresult[2]; | 962 var pname = matchresult[2]; |
963 var tag = gname + "/" + pname; | |
962 if (chunk[0] == "E") { | 964 if (chunk[0] == "E") { |
963 tslog("DGL: %s is playing %s: %s", pname, gname, fname) | 965 tslog("DGL: %s is playing %s: %s", pname, gname, fname) |
966 dglgames[tag] = fname; | |
964 } | 967 } |
965 else if (chunk[0] == "C") { | 968 else if (chunk[0] == "C") { |
966 tslog("DGL: %s started playing %s: %s", pname, gname, fname) | 969 tslog("DGL: %s started playing %s: %s", pname, gname, fname) |
970 dglgames[tag] = fname; | |
967 } | 971 } |
968 else if (chunk[0] == "D") { | 972 else if (chunk[0] == "D") { |
969 tslog("DGL: %s finished playing %s: %s", pname, gname, fname) | 973 tslog("DGL: %s finished playing %s: %s", pname, gname, fname) |
974 delete dglgames[tag]; | |
970 } | 975 } |
971 else { | 976 else { |
972 tslog("Watcher says: %s", chunk) | 977 tslog("Watcher says: %s", chunk) |
973 } | 978 } |
974 }); | 979 }); |
1052 gamedesc["n"] = sessid; | 1057 gamedesc["n"] = sessid; |
1053 gamedesc["p"] = sessions[sessid].pname; | 1058 gamedesc["p"] = sessions[sessid].pname; |
1054 gamedesc["g"] = sessions[sessid].game.uname; | 1059 gamedesc["g"] = sessions[sessid].game.uname; |
1055 statusinfo["g"].push(gamedesc); | 1060 statusinfo["g"].push(gamedesc); |
1056 } | 1061 } |
1062 statusinfo["dgl"] = []; | |
1063 for (var tag in dglgames) { | |
1064 statusinfo["dgl"].push(tag); | |
1065 } | |
1057 if (statusinfo.g.length == 0) { | 1066 if (statusinfo.g.length == 0) { |
1058 callback(statusinfo); | 1067 callback(statusinfo); |
1059 return; | 1068 return; |
1060 } | 1069 } |
1061 function makecallback(i) { | 1070 function makecallback(i) { |