changeset 132:823e878e5840

Logins don't time out anymore. No more login timestamps either.
author John "Elwin" Edwards <elwin@sdf.org>
date Wed, 12 Sep 2012 15:48:41 -0700
parents f8c89e1ed33a
children 99fbc7c55b81
files rlgwebd.js
diffstat 1 files changed, 2 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/rlgwebd.js	Wed Aug 29 15:31:13 2012 -0700
+++ b/rlgwebd.js	Wed Sep 12 15:48:41 2012 -0700
@@ -467,7 +467,6 @@
     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 @@
         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 @@
   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 @@
           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 @@
     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 @@
     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.");