jslint
This commit is contained in:
parent
6500143cdc
commit
16333ae521
1 changed files with 24 additions and 22 deletions
24
lib/rooms.js
24
lib/rooms.js
|
@ -34,7 +34,7 @@ exports.add_to_room = function (client, room, callback) {
|
||||||
room_users[room].add(client.username);
|
room_users[room].add(client.username);
|
||||||
|
|
||||||
callback(rooms[room].array());
|
callback(rooms[room].array());
|
||||||
}
|
};
|
||||||
|
|
||||||
// Remove a client from all rooms and return the username:client
|
// Remove a client from all rooms and return the username:client
|
||||||
// mapping for everybody in those rooms.
|
// 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.');
|
//console.log('Client ' + client.username + ' (' + client.id + ') disconnected.');
|
||||||
delete sid_rooms[client.id];
|
delete sid_rooms[client.id];
|
||||||
callback(affected_clients.array());
|
callback(affected_clients.array());
|
||||||
}
|
};
|
||||||
|
|
||||||
// Remove a client from a room and return the username:client mapping
|
// Remove a client from a room and return the username:client mapping
|
||||||
// for everybody in that room. Returns [] if the room does not exist,
|
// 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)
|
//gets the current room of the client (assumes one room -- will select first one if in multiple)
|
||||||
exports.get_room = function (client) {
|
exports.get_room = function (client) {
|
||||||
|
var client_rooms = null;
|
||||||
|
|
||||||
if (sid_rooms.hasOwnProperty(client.id))
|
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];
|
return client_rooms[0];
|
||||||
else
|
else
|
||||||
return null
|
return null;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
// Generic server code
|
// Generic server code
|
||||||
|
@ -147,7 +149,7 @@ exports.add_to_room_and_announce = function (client, room, msg) {
|
||||||
clients[i].json.send(msg);
|
clients[i].json.send(msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
exports.on_leave_room = function (client, room) {
|
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);
|
clients[i].json.send(msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
// Broadcasting functions
|
// Broadcasting functions
|
||||||
|
@ -221,9 +223,9 @@ exports.broadcast_to_roommates = function (client, msg) {
|
||||||
//console.log('client: ' + client.id + " is broadcasting to: ");
|
//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);
|
//console.log(' - ' + roommates[i].id);
|
||||||
roommates[i].json.send(msg);
|
roommates[k].json.send(msg);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue