Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some bugs #53

Closed
ghost opened this issue Feb 6, 2015 · 1 comment
Closed

some bugs #53

ghost opened this issue Feb 6, 2015 · 1 comment

Comments

@ghost
Copy link

ghost commented Feb 6, 2015

I use socket.io-redis for a game chat.

and daily active users are more than millions.

but we have recently found some bugs.

firstly we changed join function like the following code..

Socket.prototype.join = function(room, fn){
debug('joining room %s', room);
var self = this;
if (~this.rooms.indexOf(room)){
fn && fn();
return this;
}
this.adapter.add(this.id, room, function(err){
if (err) return fn && fn(err);
debug('joined room %s', room);
if (self.rooms.indexOf(room) == -1) {
self.rooms.push(room);
}
fn && fn(null);
});
return this;
};

the problem of the original join function is that if the user has already joined the same room as the one the user trying to join, callback function (fn) does not trigger.

secondly, if the user join a room several times (In my unittest, a user trying to join the same room thousands times),

the code..

this.adapter.add(this.id, room, function(err) <<--- will be triggered later ...

and the result is that the user has joined the same room multiple times

something like this..

socket.rooms => ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']

if you like this code, please change the source code...

@darrachequesne
Copy link
Member

Fixed in socketio/socket.io#2325

Thanks a lot for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant