Mercurial > hg > rlgwebd
changeset 109:67b393f10c2b
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.
author | John "Elwin" Edwards <elwin@sdf.org> |
---|---|
date | Sun, 15 Jul 2012 20:30:33 -0700 |
parents | 86a458080e80 |
children | 18a81cc0084b |
files | rlgterm.js rlgwebd.js |
diffstat | 2 files changed, 16 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/rlgterm.js Sun Jul 15 18:18:53 2012 -0700 +++ b/rlgterm.js Sun Jul 15 20:30:33 2012 -0700 @@ -417,6 +417,10 @@ else 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; } @@ -692,8 +696,14 @@ message("The server forgot about you, please log in again.", "warn"); } else if (reply.c == 4) { - message("You can't play that game because it is currently being " + - "played over SSH.", "warn"); + if (reply.s == "dgamelaunch") { + 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) { message("The game is being saved, try again in a few seconds.");
--- a/rlgwebd.js Sun Jul 15 18:18:53 2012 -0700 +++ b/rlgwebd.js Sun Jul 15 20:30:33 2012 -0700 @@ -756,7 +756,7 @@ var nodematch = new RegExp("^" + username + ":node:"); if (fname && (fname.match(nodematch) === null)) { /* It's being played in dgamelaunch. */ - sendError(res, 4, null); + sendError(res, 4, "dgamelaunch"); tslog("%s is already playing %s", username, gname); return; } @@ -786,7 +786,9 @@ return; } } - sendError(res, 7); + /* If there's no player, it's a WebSocket game, and shouldn't be + * seized. */ + sendError(res, 4, "WebSocket"); } else { new Player(gname, lkey, dims, respondlaunch);