diff --git a/src/app/controllers/Grbl/GrblController.js b/src/app/controllers/Grbl/GrblController.js index e9b998419..f9d35ff6b 100644 --- a/src/app/controllers/Grbl/GrblController.js +++ b/src/app/controllers/Grbl/GrblController.js @@ -410,7 +410,7 @@ class GrblController { return { port: this.options.port, baudrate: this.options.baudrate, - connections: _.size(this.connections), + connections: this.connections.map(c => c.socket.id), ready: this.ready, controller: { type: this.type, @@ -497,6 +497,8 @@ class GrblController { return !(this.isOpen()); } addConnection(socket) { + log.debug(`[Grbl] Add socket connection: id=${socket.id}`); + this.connections.push(new Connection(socket)); if (!_.isEmpty(this.state)) { @@ -510,10 +512,9 @@ class GrblController { } } removeConnection(socket) { - const index = _.findIndex(this.connections, (c) => { - return c.socket === socket; - }); - this.connections.splice(index, 1); + log.debug(`[Grbl] Remove socket connection: id=${socket.id}`); + + this.connections = this.connections.filter(c => (c.socket.id !== socket.id)); } emitAll(eventName, ...args) { this.connections.forEach((c) => { diff --git a/src/app/controllers/Smoothie/SmoothieController.js b/src/app/controllers/Smoothie/SmoothieController.js index 6aae6e498..3779354e4 100644 --- a/src/app/controllers/Smoothie/SmoothieController.js +++ b/src/app/controllers/Smoothie/SmoothieController.js @@ -366,7 +366,7 @@ class SmoothieController { return { port: this.options.port, baudrate: this.options.baudrate, - connections: _.size(this.connections), + connections: this.connections.map(c => c.socket.id), ready: this.ready, controller: { type: this.type, @@ -453,6 +453,8 @@ class SmoothieController { return !(this.isOpen()); } addConnection(socket) { + log.debug(`[Smoothie] Add socket connection: id=${socket.id}`); + this.connections.push(new Connection(socket)); if (!_.isEmpty(this.state)) { @@ -466,10 +468,9 @@ class SmoothieController { } } removeConnection(socket) { - const index = _.findIndex(this.connections, (c) => { - return c.socket === socket; - }); - this.connections.splice(index, 1); + log.debug(`[Smoothie] Remove socket connection: id=${socket.id}`); + + this.connections = this.connections.filter(c => (c.socket.id !== socket.id)); } emitAll(eventName, ...args) { this.connections.forEach((c) => { diff --git a/src/app/controllers/TinyG/TinyGController.js b/src/app/controllers/TinyG/TinyGController.js index 5476233ad..42b78f26f 100644 --- a/src/app/controllers/TinyG/TinyGController.js +++ b/src/app/controllers/TinyG/TinyGController.js @@ -421,7 +421,7 @@ class TinyGController { return { port: this.options.port, baudrate: this.options.baudrate, - connections: _.size(this.connections), + connections: this.connections.map(c => c.socket.id), ready: this.ready, controller: { type: this.type, @@ -505,6 +505,8 @@ class TinyGController { return !(this.isOpen()); } addConnection(socket) { + log.debug(`[TinyG] Add socket connection: id=${socket.id}`); + this.connections.push(new Connection(socket)); if (!_.isEmpty(this.state)) { @@ -518,10 +520,9 @@ class TinyGController { } } removeConnection(socket) { - const index = _.findIndex(this.connections, (c) => { - return c.socket === socket; - }); - this.connections.splice(index, 1); + log.debug(`[TinyG] Remove socket connection: id=${socket.id}`); + + this.connections = this.connections.filter(c => (c.socket.id !== socket.id)); } emitAll(eventName, ...args) { this.connections.forEach((c) => {