From 854519a7bd8f7ff62fcac2618e9f504b7d714fcd Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Sun, 15 Jul 2012 20:30:33 -0700 Subject: [PATCH] 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. --- rlgterm.js | 14 ++++++++++++-- rlgwebd.js | 6 ++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/rlgterm.js b/rlgterm.js index 5364e61..f3cd783 100644 --- a/rlgterm.js +++ b/rlgterm.js @@ -417,6 +417,10 @@ function setup() { 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 @@ function startgame(game) { 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."); diff --git a/rlgwebd.js b/rlgwebd.js index f798c7d..fee0c8e 100755 --- a/rlgwebd.js +++ b/rlgwebd.js @@ -756,7 +756,7 @@ function startgame(req, res, formdata) { 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 @@ function startgame(req, res, formdata) { 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);