RLG-Web: improve taking over sessions.

WebSocket sessions should not be taken over, and polling sessions are
not yet convertible to WebSockets.  Eventually the current method of
taking over via Player#reset() should be replaced with autosaving the
game, which will always work.
This commit is contained in:
John "Elwin" Edwards 2012-07-15 20:30:33 -07:00
parent 3abb05683e
commit 854519a7bd
2 changed files with 16 additions and 4 deletions

View file

@ -417,6 +417,10 @@ function setup() {
else else
break; break;
} }
if (!WebSocket) {
message("Your browser does not support WebSockets. You can still play, " +
"but it will be slower, and may not work in the future.", "warn");
}
return; return;
} }
@ -692,8 +696,14 @@ function startgame(game) {
message("The server forgot about you, please log in again.", "warn"); message("The server forgot about you, please log in again.", "warn");
} }
else if (reply.c == 4) { else if (reply.c == 4) {
message("You can't play that game because it is currently being " + if (reply.s == "dgamelaunch") {
"played over SSH.", "warn"); message("You are already playing " + game.name + " over SSH.",
"warn");
}
else {
message("You are already playing " + game.name +
" in another browser window.", "warn");
}
} }
else if (reply.c == 7) { else if (reply.c == 7) {
message("The game is being saved, try again in a few seconds."); message("The game is being saved, try again in a few seconds.");

View file

@ -756,7 +756,7 @@ function startgame(req, res, formdata) {
var nodematch = new RegExp("^" + username + ":node:"); var nodematch = new RegExp("^" + username + ":node:");
if (fname && (fname.match(nodematch) === null)) { if (fname && (fname.match(nodematch) === null)) {
/* It's being played in dgamelaunch. */ /* It's being played in dgamelaunch. */
sendError(res, 4, null); sendError(res, 4, "dgamelaunch");
tslog("%s is already playing %s", username, gname); tslog("%s is already playing %s", username, gname);
return; return;
} }
@ -786,7 +786,9 @@ function startgame(req, res, formdata) {
return; return;
} }
} }
sendError(res, 7); /* If there's no player, it's a WebSocket game, and shouldn't be
* seized. */
sendError(res, 4, "WebSocket");
} }
else { else {
new Player(gname, lkey, dims, respondlaunch); new Player(gname, lkey, dims, respondlaunch);