This commit is contained in:
ali asaria 2014-10-12 13:40:13 -04:00
parent 6500143cdc
commit 16333ae521

View file

@ -34,7 +34,7 @@ exports.add_to_room = function (client, room, callback) {
room_users[room].add(client.username);
callback(rooms[room].array());
}
};
// Remove a client from all rooms and return the username:client
// mapping for everybody in those rooms.
@ -64,7 +64,7 @@ exports.remove_from_all_rooms = function (client, callback) {
//console.log('Client ' + client.username + ' (' + client.id + ') disconnected.');
delete sid_rooms[client.id];
callback(affected_clients.array());
}
};
// Remove a client from a room and return the username:client mapping
// for everybody in that room. Returns [] if the room does not exist,
@ -122,16 +122,18 @@ exports.room_clients_other_than_me = function(room, client) {
//gets the current room of the client (assumes one room -- will select first one if in multiple)
exports.get_room = function (client) {
var client_rooms = null;
if (sid_rooms.hasOwnProperty(client.id))
{
var client_rooms = sid_rooms[client.id].array();
client_rooms = sid_rooms[client.id].array();
}
if ( typeof(client_rooms) != undefined )
if ( client_rooms !== null )
return client_rooms[0];
else
return null
}
return null;
};
// Generic server code
@ -147,7 +149,7 @@ exports.add_to_room_and_announce = function (client, room, msg) {
clients[i].json.send(msg);
}
});
}
};
/*
exports.on_leave_room = function (client, room) {
@ -174,7 +176,7 @@ exports.remove_from_all_rooms_and_announce = function (client, msg) {
clients[i].json.send(msg);
}
});
}
};
//////////////////////////////
// Broadcasting functions
@ -221,9 +223,9 @@ exports.broadcast_to_roommates = function (client, msg) {
//console.log('client: ' + client.id + " is broadcasting to: ");
for (var i = 0; i < roommates.length; i++)
for (var k = 0; k < roommates.length; k++)
{
//console.log(' - ' + roommates[i].id);
roommates[i].json.send(msg);
}
roommates[k].json.send(msg);
}
};