Logins don't time out anymore.

No more login timestamps either.
This commit is contained in:
John "Elwin" Edwards 2012-09-12 15:48:41 -07:00
parent 75db6d0f73
commit 363c88f00f

View file

@ -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.");