I giving my first steps using Node JS and things were going ok until I faced a strange behaviour that I cannot neither understand nor find an workaround for it. It should be so simple, everything is well documented and I can find so many examples of this working that I may be missing something very obvious, unfortunately. After loosing almost 2 days around this I decided to ask for some help... thanks in advance.
I am trying to store objects (clientID, socket info) in an array and want to remove an object when the connection gets lost.
I've build a small subset of my code that replicates the behaviour.
var socket = require('socket.io');
var machines = [];
var mach1 = [new socket(), new socket()];
var mach2 = [new socket(), new socket()];
var mach3 = [new socket(), new socket()];
machines["357973049420265"] = mach1;
machines["357973049420266"] = mach2;
machines["357973049420267"] = mach3;
console.log("Before : " + Object.keys(machines));
machines.splice(0,1);
console.log("After : " + Object.keys(machines));
The result is:
Before : 357973049420265, 357973049420266, 357973049420267
After : 357973049420265, 357973049420266, 357973049420267
Any ideas?
Thx