File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -336,6 +336,7 @@ describe('lib/http-proxy.js', function() {
336
336
} ) ;
337
337
} ) ;
338
338
339
+
339
340
it ( 'should proxy a socket.io stream' , function ( done ) {
340
341
var ports = { source : gen . port , proxy : gen . port } ,
341
342
proxy = httpProxy . createProxyServer ( {
@@ -370,5 +371,36 @@ describe('lib/http-proxy.js', function() {
370
371
} ) ;
371
372
} )
372
373
} ) ;
374
+
375
+
376
+ it ( 'should emit close event when socket.io client disconnects' , function ( done ) {
377
+ var ports = { source : gen . port , proxy : gen . port } ;
378
+ var proxy = httpProxy . createProxyServer ( {
379
+ target : 'ws://127.0.0.1:' + ports . source ,
380
+ ws : true
381
+ } ) ;
382
+ proxyServer = proxy . listen ( ports . proxy ) ;
383
+ var server = http . createServer ( ) ;
384
+ destiny = io . listen ( server ) ;
385
+
386
+ function startSocketIo ( ) {
387
+ var client = ioClient . connect ( 'ws://127.0.0.1:' + ports . proxy ) ;
388
+ client . on ( 'connect' , function ( ) {
389
+ client . disconnect ( ) ;
390
+ } ) ;
391
+ }
392
+
393
+ proxyServer . on ( 'close' , function ( ) {
394
+ proxyServer . close ( ) ;
395
+ server . close ( ) ;
396
+ done ( ) ;
397
+ } ) ;
398
+
399
+ server . listen ( ports . source ) ;
400
+ server . on ( 'listening' , startSocketIo ) ;
401
+
402
+ } ) ;
403
+
404
+
373
405
} )
374
406
} ) ;
You can’t perform that action at this time.
0 commit comments