File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -242,7 +242,7 @@ Socket.prototype.leave = function(room, fn){
242
242
this . adapter . del ( this . id , room , function ( err ) {
243
243
if ( err ) return fn && fn ( err ) ;
244
244
debug ( 'left room %s' , room ) ;
245
- self . rooms . splice ( self . rooms . indexOf ( room , 1 ) ) ;
245
+ self . rooms . splice ( self . rooms . indexOf ( room ) , 1 ) ;
246
246
fn && fn ( null ) ;
247
247
} ) ;
248
248
return this ;
@@ -256,6 +256,7 @@ Socket.prototype.leave = function(room, fn){
256
256
257
257
Socket . prototype . leaveAll = function ( ) {
258
258
this . adapter . delAll ( this . id ) ;
259
+ this . rooms = [ ] ;
259
260
} ;
260
261
261
262
/**
Original file line number Diff line number Diff line change @@ -1240,9 +1240,14 @@ describe('socket.io', function(){
1240
1240
expect ( s . rooms ) . to . eql ( [ s . id , 'a' ] ) ;
1241
1241
s . join ( 'b' , function ( ) {
1242
1242
expect ( s . rooms ) . to . eql ( [ s . id , 'a' , 'b' ] ) ;
1243
- s . leave ( 'b' , function ( ) {
1244
- expect ( s . rooms ) . to . eql ( [ s . id , 'a' ] ) ;
1245
- done ( ) ;
1243
+ s . join ( 'c' , function ( ) {
1244
+ expect ( s . rooms ) . to . eql ( [ s . id , 'a' , 'b' , 'c' ] ) ;
1245
+ s . leave ( 'b' , function ( ) {
1246
+ expect ( s . rooms ) . to . eql ( [ s . id , 'a' , 'c' ] ) ;
1247
+ s . leaveAll ( ) ;
1248
+ expect ( s . rooms ) . to . eql ( [ ] ) ;
1249
+ done ( ) ;
1250
+ } ) ;
1246
1251
} ) ;
1247
1252
} ) ;
1248
1253
} ) ;
You can’t perform that action at this time.
0 commit comments