I have something like this:
var users = [];
Then I use this to add to the list:
users[session] = socket;
Now I need to be able to remove from users where session and socket are the same
How would I do this? (it needs to be in plain javascript, not jquery)
This is for use in socket.IO, if anyone knows what that is.
var users = [];
////////////////USER CONNECTED
io.sockets.on('connection', function (socket) {
socket.emit('connected');
socket.on('session', function (session) {
users[session] = socket;
socket.emit("session_established");
//ON USER DISCONNECTION/////
socket.on('disconnect', function () {
//need to remove from the users list here, because they are no longer connected//
socket.broadcast.emit('disconnect', { data : session});
});
});
});
users.lengthafter your second line of posted code...