diff --git a/rlgwebd.js b/rlgwebd.js index 028fda3..c22701a 100755 --- a/rlgwebd.js +++ b/rlgwebd.js @@ -72,6 +72,8 @@ function TermSession(game, user, dims, lkey) { this.key = lkey; /* This order seems to best avoid race conditions... */ this.alive = false; + // A kludge until TermSession is rewritten to handle real watching. + this.sendq = false; this.sessid = randkey(2); while (this.sessid in sessions) { this.sessid = randkey(2); @@ -218,7 +220,7 @@ function TermSession(game, user, dims, lkey) { return; ss.record.end(); /* Give the client a chance to read any leftover data. */ - if (ss.data.length > 0) + if (ss.data.length > 0 || !ss.sendq) setTimeout(ss.remove, 8000); else ss.remove(); @@ -582,6 +584,7 @@ function endgame(term, res) { res.writeHead(200, resheaders); res.write(JSON.stringify({"t": "q"})); res.end(); + term.sendq = true; return; } @@ -653,8 +656,10 @@ function readFeed(res, term) { if (term.alive) reply.t = "n"; else { - if (allowlogin) + if (allowlogin) { reply.t = "q"; + term.sendq = true; + } else { sendError(res, 6, null); return;