Permalink
Browse files

Fixed removeUser, fixed passing options to socket.io

  • Loading branch information...
1 parent 05d1da0 commit 7e9d31cb857bec77e79833e54d26dd7de206173b @steveWang steveWang committed Jun 26, 2011
Showing with 14 additions and 9 deletions.
  1. +9 −8 lib/group.js
  2. +5 −1 lib/now.js
View
@@ -63,26 +63,27 @@ exports.initialize = function (now) {
//removes a user from the group
Group.prototype.removeUser = function (clientId) {
+ var self = this;
this.hasClient(clientId, function (hasClient) {
if (!hasClient) {
return;
}
- var user = nowUtil.clone(this.users[clientId]);
- user._events = this._events;
- this.emit.apply(user, ['leave']);
+ var user = nowUtil.clone(self.users[clientId]);
+ user._events = self._events;
+ self.emit.apply(user, ['leave']);
// Delete all remote functions that are part of this group from
// the user.
- var fqns = Object.keys(this.scopeTable.data);
+ var fqns = Object.keys(self.scopeTable.data);
for (var i = 0; i < fqns.length; i++) {
- if (typeof this.scopeTable.data[fqns[i]] === 'function' &&
- this.scopeTable.data[fqns[i]] !== nowUtil.noop &&
+ if (typeof self.scopeTable.data[fqns[i]] === 'function' &&
+ self.scopeTable.data[fqns[i]] !== nowUtil.noop &&
user.scopeTable.data[fqns[i]] === undefined) {
// Tell the user to delete his function.
user.deleteVar(fqns[i]);
}
}
- delete this.users[clientId];
- delete user.groups[this.groupName];
+ delete self.users[clientId];
+ delete user.groups[self.groupName];
});
};
View
@@ -40,7 +40,11 @@ Now.prototype.initialize = function (server, options) {
}
var self = this;
fileServer.wrapServer(server, this.options);
- this.server = io.listen(server, this.options.socketio);
+ this.server = io.listen(server);
+ for (i in this.options.socketio) {
+ this.server.set(i, this.options.socketio[i]);
+ }
+
// Need this to be separate from clientsMap.
this.server.sockets.on('connection', function (socket) {
var user = new self.User(socket);

0 comments on commit 7e9d31c

Please sign in to comment.