RLG-Web: Complete the WebSocket watcher.

Watching via WebSockets now takes into account terminal size, player
name, etc.
This commit is contained in:
John "Elwin" Edwards 2012-07-13 08:39:39 -07:00
parent aee00a29d5
commit f4c4f5e0f1
2 changed files with 13 additions and 2 deletions

View file

@ -704,12 +704,19 @@ function wsWatch(gamenumber) {
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);
}
};