comparison rlgterm.js @ 47:27b7f0c8b9f0

RLG-Web: make login sessions time out. After enough inactivity, log the user out automatically.
author John "Elwin" Edwards <elwin@sdf.org>
date Sat, 09 Jun 2012 21:20:14 -0700
parents 59ecd99845eb
children 2eda3909f6a3
comparison
equal deleted inserted replaced
46:59ecd99845eb 47:27b7f0c8b9f0
162 if (!msgDict.t) 162 if (!msgDict.t)
163 return null; 163 return null;
164 else if (msgDict.t == "E") { 164 else if (msgDict.t == "E") {
165 if (msgDict.c == 1 || msgDict.c == 6 || msgDict.c == 7) { 165 if (msgDict.c == 1 || msgDict.c == 6 || msgDict.c == 7) {
166 gameover(); 166 gameover();
167 if (msgDict.c == 1) {
168 logout();
169 }
167 } 170 }
168 debug(1, "Server error: " + msgDict.s); 171 debug(1, "Server error: " + msgDict.s);
169 } 172 }
170 else if (msgDict.t == "n") { 173 else if (msgDict.t == "n") {
171 havedata = false; 174 havedata = false;
494 setmode("play"); 497 setmode("play");
495 getData(); 498 getData();
496 } 499 }
497 else if (reply.t == 'E') { 500 else if (reply.t == 'E') {
498 debug(1, "Could not start game: " + reply.s); 501 debug(1, "Could not start game: " + reply.s);
502 if (reply.c == 1) {
503 logout();
504 }
499 } 505 }
500 }; 506 };
501 req.open('POST', '/play', true); 507 req.open('POST', '/play', true);
502 req.send(JSON.stringify(smsg)); 508 req.send(JSON.stringify(smsg));
503 return; 509 return;
549 msgQ = []; 555 msgQ = [];
550 setmode("choose"); 556 setmode("choose");
551 return; 557 return;
552 } 558 }
553 559
560 function logout() {
561 lcred = null;
562 lname = null;
563 setmode("login");
564 }
565
554 function stop() { 566 function stop() {
555 if (!termemu.sessid) 567 if (!termemu.sessid)
556 return; 568 return;
557 var req = new XMLHttpRequest(); 569 var req = new XMLHttpRequest();
558 req.onreadystatechange = function () { 570 req.onreadystatechange = function () {