added methods and socket listeners for group joining and leaving, #2588

This commit is contained in:
Julian Lam
2015-01-07 16:55:14 -05:00
parent 501935d359
commit 9fa3675424
2 changed files with 49 additions and 0 deletions

23
src/socket.io/groups.js Normal file
View File

@@ -0,0 +1,23 @@
"use strict";
var groups = require('../groups'),
SocketGroups = {};
SocketGroups.join = function(socket, data, callback) {
if (!data) {
return callback(new Error('[[error:invalid-data]]'));
}
groups.join(data.groupName, socket.uid, callback);
};
SocketGroups.leave = function(socket, data, callback) {
if (!data) {
return callback(new Error('[[error:invalid-data]]'));
}
groups.leave(data.groupName, socket.uid, callback);
};
module.exports = SocketGroups;