diff --git a/rlgwebd.js b/rlgwebd.js index a9df6eb..b3bddc9 100755 --- a/rlgwebd.js +++ b/rlgwebd.js @@ -131,8 +131,6 @@ function TermSession(game, lkey, dims, handlers) { * with a complete screen. */ this.framebuf = new Buffer(1024); this.frameoff = 0; - /* List of WebSockets watching the game. */ - this.watchsocks = []; logins[lkey].sessions.push(this.sessid); /* END setup */ function ttyrec_chunk(datastr) { @@ -171,21 +169,6 @@ function TermSession(game, lkey, dims, handlers) { this.write = function(data) { this.term.write(data); }; - // WebSocket watchers. - this.addWS = function (conn) { - this.watchsocks.push(conn); - }; - this.removeWS = function (conn) { - var i = this.watchsocks.indexOf(conn); - if (i >= 0) { - if (conn.connected) - conn.close(); - this.watchsocks.splice(i, 1); - return true; - } - else - return false; - }; // Teardown. this.term.on("exit", function () { fs.unlink(ss.lock); @@ -388,7 +371,8 @@ function wsWatcher(conn, session) { conn.on('close', function(code, desc) { session.removeListener('data', dataH); session.removeListener('exit', exitH); - tslog("A WebSocket watcher has left game %d", session.sessid); + if (session.sessid in sessions) + tslog("A WebSocket watcher has left game %d", session.sessid); }); conn.sendUTF(JSON.stringify({ "t": "w", "w": session.w, "h": session.h,