leaveRoom method, small fixes

This commit is contained in:
barisusakli
2015-12-16 11:30:10 +02:00
parent f8a6666e1a
commit 8fab270852
6 changed files with 22 additions and 4 deletions

View File

@@ -12,6 +12,8 @@ var sockets = require('../socket.io');
module.exports = function(Messaging) {
Messaging.notifyQueue = {}; // Only used to notify a user of a new chat message, see Messaging.notifyUser
Messaging.notifyUsersInRoom = function(fromUid, roomId, messageObj) {
Messaging.getUidsInRoom(roomId, 0, -1, function(err, uids) {
if (err) {

View File

@@ -45,6 +45,17 @@ module.exports = function(Messaging) {
], callback);
};
Messaging.leaveRoom = function(uid, roomId, callback) {
async.waterfall([
function (next) {
db.sortedSetRemove('chat:room:' + roomId + ':uids', uid, next);
},
function (next) {
db.sortedSetRemove('uid:' + uid + ':chat:rooms', roomId, next);
}
], callback);
};
Messaging.getUidsInRoom = function(roomId, start, stop, callback) {
db.getSortedSetRange('chat:room:' + roomId + ':uids', start, stop, callback);
};