@@ -313,11 +313,8 @@ impl Socket {
313
313
PacketId :: Message => {
314
314
self . socket . handle_data ( packet. data . clone ( ) ) ?;
315
315
}
316
-
317
316
PacketId :: Close => {
318
317
self . socket . handle_close ( ) ?;
319
- // set current state to not connected and stop polling
320
- self . socket . disconnect ( ) ?;
321
318
}
322
319
PacketId :: Open => {
323
320
unreachable ! ( "Won't happen as we open the connection beforehand" ) ;
@@ -448,16 +445,36 @@ mod test {
448
445
socket. close ( )
449
446
}
450
447
448
+ #[ test]
449
+ fn test_connection_long ( ) -> Result < ( ) > {
450
+ // Long lived socket to receive pings
451
+ let url = crate :: test:: engine_io_server ( ) ?;
452
+ let socket = builder ( url) . build ( ) ?;
453
+
454
+ socket. connect ( ) ?;
455
+
456
+ let mut iter = socket. iter ( ) ;
457
+ // hello client
458
+ iter. next ( ) ;
459
+ // Ping
460
+ iter. next ( ) ;
461
+
462
+ socket. disconnect ( ) ?;
463
+
464
+ assert ! ( !socket. is_connected( ) ?) ;
465
+
466
+ Ok ( ( ) )
467
+ }
468
+
451
469
#[ test]
452
470
fn test_connection_dynamic ( ) -> Result < ( ) > {
453
471
let url = crate :: test:: engine_io_server ( ) ?;
454
472
let socket = builder ( url) . build ( ) ?;
455
473
test_connection ( socket) ?;
456
474
457
475
let url = crate :: test:: engine_io_polling_server ( ) ?;
458
- assert ! ( builder( url) . build( ) . is_err( ) ) ;
459
-
460
- Ok ( ( ) )
476
+ let socket = builder ( url) . build ( ) ?;
477
+ test_connection ( socket)
461
478
}
462
479
463
480
#[ test]
@@ -489,6 +506,9 @@ mod test {
489
506
490
507
#[ test]
491
508
fn test_connection_wss ( ) -> Result < ( ) > {
509
+ let url = crate :: test:: engine_io_polling_server ( ) ?;
510
+ assert ! ( builder( url) . build_websocket_with_upgrade( ) . is_err( ) ) ;
511
+
492
512
let host =
493
513
std:: env:: var ( "ENGINE_IO_SECURE_HOST" ) . unwrap_or_else ( |_| "localhost" . to_owned ( ) ) ;
494
514
let mut url = crate :: test:: engine_io_server_secure ( ) ?;
@@ -521,6 +541,9 @@ mod test {
521
541
522
542
#[ test]
523
543
fn test_connection_ws ( ) -> Result < ( ) > {
544
+ let url = crate :: test:: engine_io_polling_server ( ) ?;
545
+ assert ! ( builder( url) . build_websocket( ) . is_err( ) ) ;
546
+
524
547
let mut url = crate :: test:: engine_io_server ( ) ?;
525
548
526
549
let builder = builder ( url. clone ( ) ) ;
0 commit comments