mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
Trigger callback even when joining an already joined room
This commit is contained in:
@@ -222,7 +222,10 @@ Socket.prototype.packet = function(packet, opts){
|
||||
Socket.prototype.join = function(room, fn){
|
||||
debug('joining room %s', room);
|
||||
var self = this;
|
||||
if (this.rooms.hasOwnProperty(room)) return this;
|
||||
if (this.rooms.hasOwnProperty(room)) {
|
||||
fn && fn(null);
|
||||
return this;
|
||||
}
|
||||
this.adapter.add(this.id, room, function(err){
|
||||
if (err) return fn && fn(err);
|
||||
debug('joined room %s', room);
|
||||
|
||||
@@ -1685,6 +1685,21 @@ describe('socket.io', function(){
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should always trigger the callback (if provided) when joining a room', function(done){
|
||||
var srv = http();
|
||||
var sio = io(srv);
|
||||
|
||||
srv.listen(function(){
|
||||
var socket = client(srv);
|
||||
sio.on('connection', function(s){
|
||||
s.join('a', function(){
|
||||
s.join('a', done);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('messaging many', function(){
|
||||
|
||||
Reference in New Issue
Block a user