Mercurial > hg > rlgwebd
comparison rlgterm.js @ 101:e59d68082664
RLG-Web: Complete the WebSocket watcher.
Watching via WebSockets now takes into account terminal size, player
name, etc.
author | John "Elwin" Edwards <elwin@sdf.org> |
---|---|
date | Fri, 13 Jul 2012 08:39:39 -0700 |
parents | 3dbfdaf62623 |
children | a9371002aecc |
comparison
equal
deleted
inserted
replaced
100:3dbfdaf62623 | 101:e59d68082664 |
---|---|
702 var sockurl = "ws://localhost:8080/watch/" + String(gamenumber); | 702 var sockurl = "ws://localhost:8080/watch/" + String(gamenumber); |
703 var ws = new WebSocket(sockurl); | 703 var ws = new WebSocket(sockurl); |
704 ws.onopen = function (event) { | 704 ws.onopen = function (event) { |
705 session.id = true; | 705 session.id = true; |
706 session.sock = ws; | 706 session.sock = ws; |
707 message("You are now watching game #" + gamenumber + "."); | |
708 setmode("watch"); | 707 setmode("watch"); |
709 }; | 708 }; |
710 ws.onmessage = function (event) { | 709 ws.onmessage = function (event) { |
711 var msgObject = JSON.parse(event.data); | 710 var msgObject = JSON.parse(event.data); |
712 if (msgObject.t == 'd') { | 711 if (msgObject.t == 'w') { |
712 termemu.resize(msgObject.h, msgObject.w); | |
713 termemu.reset(); | |
714 termemu.toAltBuf(); | |
715 var pname = msgObject.p; | |
716 var gname = games[msgObject.g].name; | |
717 message("You are now watching " + pname + " play " + gname + "."); | |
718 } | |
719 else if (msgObject.t == 'd') { | |
713 writeData(msgObject.d); | 720 writeData(msgObject.d); |
714 } | 721 } |
715 }; | 722 }; |
716 ws.onclose = function (event) { | 723 ws.onclose = function (event) { |
717 session.sock = null; | 724 session.sock = null; |