« get me outta code hell

Properly disconnect all clients! - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-07-07 16:51:14 -0300
committerFlorrie <towerofnix@gmail.com>2019-07-07 16:51:14 -0300
commitd7f31bd2541e5d37057136bc34e3f9603803ab57 (patch)
tree3a0138d58c6ee4d2de36aded14c87bf2c5e1d1b8
parent22c1ebc729c7f2a0b7245fd8b79f2ef360d42279 (diff)
Properly disconnect all clients!
-rw-r--r--telnet-server.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/telnet-server.js b/telnet-server.js
index cda3323..6111d9d 100644
--- a/telnet-server.js
+++ b/telnet-server.js
@@ -46,7 +46,7 @@ class TelnetServer {
       socket.end()
       flushable.end()
       closed = true
-      this.sockets.splice(this.sockets.indexOf(socket, 1))
+      this.sockets.splice(this.sockets.indexOf(socket), 1)
     }
 
     appElement.on('quitRequested', quit)
@@ -56,7 +56,7 @@ class TelnetServer {
         clearInterval(renderInterval)
         flushable.end()
         closed = true
-        this.sockets.splice(this.sockets.indexOf(socket, 1))
+        this.sockets.splice(this.sockets.indexOf(socket), 1)
       }
     })
 
@@ -65,8 +65,8 @@ class TelnetServer {
   }
 
   disconnectAllSockets(msg) {
-    for (const socket of this.sockets) {
-      socket.quit(msg)
+    while (this.sockets.length) {
+      this.sockets[0].quit(msg)
     }
   }
 }