diff options
-rw-r--r-- | client.js | 2 | ||||
-rw-r--r-- | telnet-server.js | 8 |
2 files changed, 6 insertions, 4 deletions
diff --git a/client.js b/client.js index 7f21d1a..a0c8352 100644 --- a/client.js +++ b/client.js @@ -82,7 +82,7 @@ const setupClient = async ({backend, writable, interfacer, appConfig}) => { flushable.flush() }, 100) - return {appElement, cleanTerminal, renderInterval} + return {appElement, cleanTerminal, flushable, renderInterval} } module.exports = setupClient diff --git a/telnet-server.js b/telnet-server.js index 6cee554..479bd2b 100644 --- a/telnet-server.js +++ b/telnet-server.js @@ -22,7 +22,7 @@ class TelnetServer { async handleConnection(socket) { const interfacer = new TelnetInterfacer(socket) - const { appElement, renderInterval, cleanTerminal } = await setupClient({ + const { appElement, cleanTerminal, flushable, renderInterval } = await setupClient({ backend: this.backend, writable: socket, interfacer, @@ -39,8 +39,9 @@ class TelnetServer { interfacer.cleanTelnetOptions() socket.write('\r' + msg + '\r\n') socket.end() - this.sockets.splice(this.sockets.indexOf(socket, 1)) + flushable.end() closed = true + this.sockets.splice(this.sockets.indexOf(socket, 1)) } appElement.on('quitRequested', quit) @@ -48,8 +49,9 @@ class TelnetServer { socket.on('close', () => { if (!closed) { clearInterval(renderInterval) - this.sockets.splice(this.sockets.indexOf(socket, 1)) + flushable.end() closed = true + this.sockets.splice(this.sockets.indexOf(socket, 1)) } }) |