File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -199,9 +199,10 @@ Client.prototype.onclose = function(reason){
199
199
this . destroy ( ) ;
200
200
201
201
// `nsps` and `sockets` are cleaned up seamlessly
202
- this . sockets . forEach ( function ( socket ) {
202
+ var socket ;
203
+ while ( socket = this . sockets . shift ( ) ) {
203
204
socket . onclose ( reason ) ;
204
- } ) ;
205
+ }
205
206
206
207
this . decoder . destroy ( ) ; // clean up decoder
207
208
} ;
Original file line number Diff line number Diff line change @@ -395,6 +395,33 @@ describe('socket.io', function(){
395
395
}
396
396
} ) ;
397
397
} ) ;
398
+
399
+ it ( 'should disconnect both default and custom namespace upon disconnect' , function ( done ) {
400
+ var srv = http ( ) ;
401
+ var sio = io ( srv ) ;
402
+ srv . listen ( function ( ) {
403
+ var lolcats = client ( srv , '/lolcats' ) ;
404
+ var total = 2 ;
405
+ var totald = 2 ;
406
+ var s ;
407
+ sio . of ( '/' , function ( socket ) {
408
+ socket . on ( 'disconnect' , function ( reason ) {
409
+ -- totald || done ( ) ;
410
+ } ) ;
411
+ -- total || close ( ) ;
412
+ } ) ;
413
+ sio . of ( '/lolcats' , function ( socket ) {
414
+ s = socket ;
415
+ socket . on ( 'disconnect' , function ( reason ) {
416
+ -- totald || done ( ) ;
417
+ } ) ;
418
+ -- total || close ( ) ;
419
+ } ) ;
420
+ function close ( ) {
421
+ s . disconnect ( true ) ;
422
+ }
423
+ } ) ;
424
+ } ) ;
398
425
} ) ;
399
426
} ) ;
400
427
You can’t perform that action at this time.
0 commit comments