You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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...
The text was updated successfully, but these errors were encountered: