# HG changeset patch # User John "Elwin" Edwards # Date 1342193979 25200 # Node ID e59d68082664eac319f17e4584cad24cc2c1a153 # Parent 3dbfdaf626232f96d05fc54093bf3e90c2c30716 RLG-Web: Complete the WebSocket watcher. Watching via WebSockets now takes into account terminal size, player name, etc. diff -r 3dbfdaf62623 -r e59d68082664 rlgterm.js --- a/rlgterm.js Thu Jul 12 22:16:15 2012 -0700 +++ b/rlgterm.js Fri Jul 13 08:39:39 2012 -0700 @@ -704,12 +704,19 @@ ws.onopen = function (event) { session.id = true; session.sock = ws; - message("You are now watching game #" + gamenumber + "."); setmode("watch"); }; ws.onmessage = function (event) { var msgObject = JSON.parse(event.data); - if (msgObject.t == 'd') { + if (msgObject.t == 'w') { + termemu.resize(msgObject.h, msgObject.w); + termemu.reset(); + termemu.toAltBuf(); + var pname = msgObject.p; + var gname = games[msgObject.g].name; + message("You are now watching " + pname + " play " + gname + "."); + } + else if (msgObject.t == 'd') { writeData(msgObject.d); } }; diff -r 3dbfdaf62623 -r e59d68082664 rlgwebd.js --- a/rlgwebd.js Thu Jul 12 22:16:15 2012 -0700 +++ b/rlgwebd.js Fri Jul 13 08:39:39 2012 -0700 @@ -390,6 +390,10 @@ session.removeListener('exit', exitH); tslog("A WebSocket watcher has left game %d", session.sessid); }); + conn.sendUTF(JSON.stringify({ + "t": "w", "w": session.w, "h": session.h, + "p": session.pname, "g": session.game.uname + })); conn.sendUTF(JSON.stringify({"t": "d", "d": session.framebuf.toString("hex", 0, session.frameoff)})); }