From 363c88f00f9bdd9a5d47497c24b9f71f550931da Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Wed, 12 Sep 2012 15:48:41 -0700 Subject: [PATCH] Logins don't time out anymore. No more login timestamps either. --- rlgwebd.js | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/rlgwebd.js b/rlgwebd.js index d262616..c5aa04d 100755 --- a/rlgwebd.js +++ b/rlgwebd.js @@ -467,7 +467,6 @@ function wsStart(wsReq) { wsReq.reject(404, errorcodes[1]); return; } - logins[lkey].ts = new Date(); var pname = logins[lkey].name; var dims = [wsReq.resourceURL.query.h, wsReq.resourceURL.query.w]; function progcallback(err, fname) { @@ -642,8 +641,6 @@ function reaper() { var sn = logins[session.key].sessions.indexOf(session.sessid); if (sn >= 0) { logins[session.key].sessions.splice(sn, 1); - if (now - logins[session.key].ts > playtimeout) - logins[session.key].ts = new Date(now - playtimeout); } /* Shut it down. */ session.close(); @@ -653,19 +650,9 @@ function reaper() { for (var sessid in sessions) { reapcheck(sessions[sessid]); } - /* HELPME this is about as clever as I can code, so I can't tell whether - * there are any bugs. */ for (var lkey in logins) { - if (logins[lkey].sessions.length == 0) { - /* A login with no current games can be killed for inactivity. */ - if (now - logins[lkey].ts > playtimeout * 4) { - tslog("Login for %s (key %s) timed out", logins[lkey].name, lkey); - delete logins[lkey]; - } - } - else { - /* Check for games that have terminated normally, and update - * the timestamp. */ + if (logins[lkey].sessions.length > 0) { + /* Check for games that have terminated normally, and remove them. */ var expired = []; var targarray = logins[lkey].sessions; /* Let's not find out what happens if you modify an array @@ -675,7 +662,6 @@ function reaper() { expired.push(targarray[i]); } if (expired.length > 0) { - logins[lkey].ts = new Date(now); for (var j = 0; j < expired.length; j++) { targarray.splice(targarray.indexOf(expired[j]), 1); } @@ -747,9 +733,6 @@ function startgame(req, res, formdata) { sendError(res, 1, null); return; } - else { - logins[lkey].ts = new Date(); - } var username = logins[lkey].name; var gname = formdata["game"]; // If dims are not given or invalid, the constructor will handle it. @@ -910,8 +893,6 @@ function stopgame(res, formdata) { sendError(res, 1); return; } - /* Update timestamp, because this is an authenticated action. */ - logins[formdata["key"]].ts = new Date(); var pname = logins[formdata["key"]].name; if (!("g" in formdata) || !(formdata["g"] in games)) { sendError(res, 2, "No such game.");