RLG-Web server: code cleanup.

Delete some TermSession code left over from the first attempt at
Websockets.  Also don't bother logging the disconnection of watchers
after the game has ended.
This commit is contained in:
John "Elwin" Edwards 2012-07-13 08:52:17 -07:00
parent f4c4f5e0f1
commit 031bc239f8

View file

@ -131,8 +131,6 @@ function TermSession(game, lkey, dims, handlers) {
* with a complete screen. */ * with a complete screen. */
this.framebuf = new Buffer(1024); this.framebuf = new Buffer(1024);
this.frameoff = 0; this.frameoff = 0;
/* List of WebSockets watching the game. */
this.watchsocks = [];
logins[lkey].sessions.push(this.sessid); logins[lkey].sessions.push(this.sessid);
/* END setup */ /* END setup */
function ttyrec_chunk(datastr) { function ttyrec_chunk(datastr) {
@ -171,21 +169,6 @@ function TermSession(game, lkey, dims, handlers) {
this.write = function(data) { this.write = function(data) {
this.term.write(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. // Teardown.
this.term.on("exit", function () { this.term.on("exit", function () {
fs.unlink(ss.lock); fs.unlink(ss.lock);
@ -388,7 +371,8 @@ function wsWatcher(conn, session) {
conn.on('close', function(code, desc) { conn.on('close', function(code, desc) {
session.removeListener('data', dataH); session.removeListener('data', dataH);
session.removeListener('exit', exitH); 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({ conn.sendUTF(JSON.stringify({
"t": "w", "w": session.w, "h": session.h, "t": "w", "w": session.w, "h": session.h,