]> git.cworth.org Git - lmno-server/commitdiff
game: Fix to actually drop connections that get closed
authorCarl Worth <cworth@cworth.org>
Thu, 25 Jun 2020 01:28:34 +0000 (18:28 -0700)
committerCarl Worth <cworth@cworth.org>
Fri, 26 Jun 2020 14:37:59 +0000 (07:37 -0700)
The bug here is that filter() returns a new array, so I have to assign
the return value to the original reference for this code to have any
effect.

game.js

diff --git a/game.js b/game.js
index 5a49b6bdd52b5aaf753ca3469e14618cd1548c9a..4649b56704a41f8c103e492c09560344cfadb299 100644 (file)
--- a/game.js
+++ b/game.js
@@ -23,7 +23,7 @@ class Player {
 
   /* Returns the number of remaining connections after this one is removed. */
   remove_connection(connection) {
-    this.connections.filter(c => c !== connection);
+    this.connections = this.connections.filter(c => c !== connection);
     return this.connections.length;
   }