comparison rlgwebd.js @ 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 b64e31c5ec31
children 18a81cc0084b
comparison
equal deleted inserted replaced
108:86a458080e80 109:67b393f10c2b
754 // A callback to pass to the game-in-progress checker. 754 // A callback to pass to the game-in-progress checker.
755 var launch = function(err, fname) { 755 var launch = function(err, fname) {
756 var nodematch = new RegExp("^" + username + ":node:"); 756 var nodematch = new RegExp("^" + username + ":node:");
757 if (fname && (fname.match(nodematch) === null)) { 757 if (fname && (fname.match(nodematch) === null)) {
758 /* It's being played in dgamelaunch. */ 758 /* It's being played in dgamelaunch. */
759 sendError(res, 4, null); 759 sendError(res, 4, "dgamelaunch");
760 tslog("%s is already playing %s", username, gname); 760 tslog("%s is already playing %s", username, gname);
761 return; 761 return;
762 } 762 }
763 // Game starting has been approved. 763 // Game starting has been approved.
764 var respondlaunch = function(nclient, success) { 764 var respondlaunch = function(nclient, success) {
784 respondlaunch(cli, true); 784 respondlaunch(cli, true);
785 tslog("Game %d has been taken over.", cli.session.sessid); 785 tslog("Game %d has been taken over.", cli.session.sessid);
786 return; 786 return;
787 } 787 }
788 } 788 }
789 sendError(res, 7); 789 /* If there's no player, it's a WebSocket game, and shouldn't be
790 * seized. */
791 sendError(res, 4, "WebSocket");
790 } 792 }
791 else { 793 else {
792 new Player(gname, lkey, dims, respondlaunch); 794 new Player(gname, lkey, dims, respondlaunch);
793 } 795 }
794 }; 796 };