@@ -2635,4 +2635,82 @@ module.exports = {
2635
2635
} ) ;
2636
2636
} ,
2637
2637
2638
+ 'test emitting to closed clients' : function ( done ) {
2639
+ var cl = client ( ++ ports )
2640
+ , cl2 = client ( ports )
2641
+ , io = create ( cl )
2642
+ , connections = 0 ;
2643
+
2644
+ io . configure ( function ( ) {
2645
+ io . set ( 'close timeout' , .1 ) ;
2646
+ } ) ;
2647
+
2648
+ io . sockets . on ( 'connection' , function ( socket ) {
2649
+ socket . send ( 'a' ) ;
2650
+ } ) ;
2651
+
2652
+ cl . handshake ( function ( sid ) {
2653
+ cl . get ( '/socket.io/{protocol}/xhr-polling/' + sid , function ( res , packs ) {
2654
+ res . statusCode . should . equal ( 200 ) ;
2655
+ packs . should . have . length ( 1 ) ;
2656
+ packs [ 0 ] . should . eql ( { type : 'message' , endpoint : '' , data : 'a' } ) ;
2657
+
2658
+ cl2 . handshake ( function ( sid2 ) {
2659
+ cl2 . get (
2660
+ '/socket.io/{protocol}/xhr-polling/' + sid2
2661
+ , function ( res , packs ) {
2662
+ res . statusCode . should . equal ( 200 ) ;
2663
+ packs . should . have . length ( 1 ) ;
2664
+ packs [ 0 ] . should . eql ( { type : 'message' , endpoint : '' , data : 'a' } ) ;
2665
+
2666
+ io . sockets . emit ( 'woot' , 'b' ) ;
2667
+
2668
+ var total = 2 ;
2669
+
2670
+ cl . get (
2671
+ '/socket.io/{protocol}/xhr-polling/' + sid
2672
+ , function ( res , packs ) {
2673
+ res . statusCode . should . equal ( 200 ) ;
2674
+ packs . should . have . length ( 1 ) ;
2675
+ packs [ 0 ] . should . eql ( {
2676
+ type : 'event'
2677
+ , endpoint : ''
2678
+ , name : 'woot'
2679
+ , args : [ 'b' ]
2680
+ } ) ;
2681
+
2682
+ -- total || finish ( ) ;
2683
+ }
2684
+ ) ;
2685
+
2686
+ cl2 . get (
2687
+ '/socket.io/{protocol}/xhr-polling/' + sid2
2688
+ , function ( res , packs ) {
2689
+ res . statusCode . should . equal ( 200 ) ;
2690
+ packs . should . have . length ( 1 ) ;
2691
+ packs [ 0 ] . should . eql ( {
2692
+ type : 'event'
2693
+ , endpoint : ''
2694
+ , name : 'woot'
2695
+ , args : [ 'b' ]
2696
+ } ) ;
2697
+
2698
+ -- total || finish ( ) ;
2699
+ }
2700
+ ) ;
2701
+
2702
+ function finish ( ) {
2703
+ cl . end ( ) ;
2704
+ cl2 . end ( ) ;
2705
+ io . server . close ( ) ;
2706
+ done ( ) ;
2707
+ } ;
2708
+ }
2709
+ ) ;
2710
+ } ) ;
2711
+
2712
+ } ) ;
2713
+ } ) ;
2714
+ }
2715
+
2638
2716
} ;
0 commit comments