diff rlgwebd.js @ 102:f34a286c51bd

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.
author John "Elwin" Edwards <elwin@sdf.org>
date Fri, 13 Jul 2012 08:52:17 -0700
parents e59d68082664
children f30495f7ede8
line wrap: on
line diff
--- a/rlgwebd.js	Fri Jul 13 08:39:39 2012 -0700
+++ b/rlgwebd.js	Fri Jul 13 08:52:17 2012 -0700
@@ -131,8 +131,6 @@
    * 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 @@
   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 @@
   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,