@@ -211,7 +211,7 @@ TEST(start, start_fails_for_handshake_response_with_error)
211
211
auto websocket_client = create_test_websocket_client ();
212
212
auto hub_connection = create_hub_connection (websocket_client);
213
213
std::exception_ptr exception ;
214
- hub_connection. set_disconnected ([&exception ](std::exception_ptr ex)
214
+ hub_connection-> set_disconnected ([&exception ](std::exception_ptr ex)
215
215
{
216
216
exception = ex;
217
217
});
@@ -255,7 +255,7 @@ TEST(start, start_fails_if_non_handshake_message_received)
255
255
auto hub_connection = create_hub_connection (websocket_client);
256
256
257
257
auto mre = manual_reset_event<void >();
258
- hub_connection. start ([&mre](std::exception_ptr exception )
258
+ hub_connection-> start ([&mre](std::exception_ptr exception )
259
259
{
260
260
mre.set (exception );
261
261
});
@@ -274,7 +274,7 @@ TEST(start, start_fails_if_non_handshake_message_received)
274
274
ASSERT_STREQ (" Received unexpected message while waiting for the handshake response." , ex.what ());
275
275
}
276
276
277
- ASSERT_EQ (connection_state::disconnected, hub_connection. get_connection_state ());
277
+ ASSERT_EQ (connection_state::disconnected, hub_connection-> get_connection_state ());
278
278
}
279
279
280
280
TEST (start, on_not_called_if_multiple_messages_received_before_handshake)
@@ -283,13 +283,13 @@ TEST(start, on_not_called_if_multiple_messages_received_before_handshake)
283
283
auto hub_connection = create_hub_connection (websocket_client);
284
284
285
285
bool on_called = false ;
286
- hub_connection. on (" Target" , [&on_called](signalr::value)
286
+ hub_connection-> on (" Target" , [&on_called](signalr::value)
287
287
{
288
288
on_called = true ;
289
289
});
290
290
291
291
auto mre = manual_reset_event<void >();
292
- hub_connection. start ([&mre](std::exception_ptr exception )
292
+ hub_connection-> start ([&mre](std::exception_ptr exception )
293
293
{
294
294
mre.set (exception );
295
295
});
@@ -308,7 +308,7 @@ TEST(start, on_not_called_if_multiple_messages_received_before_handshake)
308
308
ASSERT_STREQ (" Received unexpected message while waiting for the handshake response." , ex.what ());
309
309
}
310
310
311
- ASSERT_EQ (connection_state::disconnected, hub_connection. get_connection_state ());
311
+ ASSERT_EQ (connection_state::disconnected, hub_connection-> get_connection_state ());
312
312
313
313
ASSERT_FALSE (on_called);
314
314
}
@@ -404,10 +404,10 @@ TEST(start, start_fails_if_handshake_times_out)
404
404
auto hub_connection = create_hub_connection (websocket_client);
405
405
auto config = signalr_client_config ();
406
406
config.set_handshake_timeout (std::chrono::seconds (1 ));
407
- hub_connection. set_client_config (config);
407
+ hub_connection-> set_client_config (config);
408
408
409
409
auto mre = manual_reset_event<void >();
410
- hub_connection. start ([&mre](std::exception_ptr exception )
410
+ hub_connection-> start ([&mre](std::exception_ptr exception )
411
411
{
412
412
mre.set (exception );
413
413
});
@@ -425,7 +425,7 @@ TEST(start, start_fails_if_handshake_times_out)
425
425
ASSERT_STREQ (" timed out waiting for the server to respond to the handshake message." , ex.what ());
426
426
}
427
427
428
- ASSERT_EQ (connection_state::disconnected, hub_connection. get_connection_state ());
428
+ ASSERT_EQ (connection_state::disconnected, hub_connection-> get_connection_state ());
429
429
}
430
430
431
431
TEST (start, propogates_exception_from_negotiate)
@@ -447,7 +447,7 @@ TEST(start, propogates_exception_from_negotiate)
447
447
.build ();
448
448
449
449
auto mre = manual_reset_event<void >();
450
- hub_connection. start ([&mre](std::exception_ptr exception )
450
+ hub_connection-> start ([&mre](std::exception_ptr exception )
451
451
{
452
452
mre.set (exception );
453
453
});
@@ -462,7 +462,7 @@ TEST(start, propogates_exception_from_negotiate)
462
462
ASSERT_STREQ (" custom exception" , e.what ());
463
463
}
464
464
465
- ASSERT_EQ (connection_state::disconnected, hub_connection. get_connection_state ());
465
+ ASSERT_EQ (connection_state::disconnected, hub_connection-> get_connection_state ());
466
466
}
467
467
468
468
// regression test: helps ensure internal state is in a working state for connecting again after connection failures
@@ -495,13 +495,13 @@ TEST(start, propogates_exception_from_negotiate_and_can_start_again)
495
495
.build ();
496
496
497
497
std::atomic<bool > disconnected { false };
498
- hub_connection. set_disconnected ([&disconnected](std::exception_ptr ex)
498
+ hub_connection-> set_disconnected ([&disconnected](std::exception_ptr ex)
499
499
{
500
500
disconnected.store (true );
501
501
});
502
502
503
503
auto mre = manual_reset_event<void >();
504
- hub_connection. start ([&mre](std::exception_ptr exception )
504
+ hub_connection-> start ([&mre](std::exception_ptr exception )
505
505
{
506
506
mre.set (exception );
507
507
});
@@ -518,7 +518,7 @@ TEST(start, propogates_exception_from_negotiate_and_can_start_again)
518
518
519
519
ASSERT_FALSE (disconnected.load ());
520
520
521
- hub_connection. start ([&mre](std::exception_ptr exception )
521
+ hub_connection-> start ([&mre](std::exception_ptr exception )
522
522
{
523
523
mre.set (exception );
524
524
});
@@ -533,7 +533,7 @@ TEST(start, propogates_exception_from_negotiate_and_can_start_again)
533
533
ASSERT_STREQ (" custom exception 2" , e.what ());
534
534
}
535
535
536
- ASSERT_EQ (connection_state::disconnected, hub_connection. get_connection_state ());
536
+ ASSERT_EQ (connection_state::disconnected, hub_connection-> get_connection_state ());
537
537
ASSERT_FALSE (disconnected.load ());
538
538
}
539
539
@@ -754,10 +754,10 @@ TEST(stop, transport_error_propogates_to_disconnected_callback)
754
754
auto hub_connection = create_hub_connection (websocket_client);
755
755
756
756
auto disconnected_invoked = manual_reset_event<void >();
757
- hub_connection. set_disconnected ([&disconnected_invoked](std::exception_ptr exception ) { disconnected_invoked.set (exception ); });
757
+ hub_connection-> set_disconnected ([&disconnected_invoked](std::exception_ptr exception ) { disconnected_invoked.set (exception ); });
758
758
759
759
auto mre = manual_reset_event<void >();
760
- hub_connection. start ([&mre](std::exception_ptr exception )
760
+ hub_connection-> start ([&mre](std::exception_ptr exception )
761
761
{
762
762
mre.set (exception );
763
763
});
@@ -779,7 +779,7 @@ TEST(stop, transport_error_propogates_to_disconnected_callback)
779
779
{
780
780
ASSERT_STREQ (" transport error" , e.what ());
781
781
}
782
- ASSERT_EQ (connection_state::disconnected, hub_connection. get_connection_state ());
782
+ ASSERT_EQ (connection_state::disconnected, hub_connection-> get_connection_state ());
783
783
}
784
784
785
785
TEST (stop, connection_stopped_when_going_out_of_scope)
@@ -839,7 +839,7 @@ TEST(stop, stop_cancels_pending_callbacks)
839
839
mre.get ();
840
840
841
841
auto invoke_mre = manual_reset_event<void >();
842
- hub_connection. invoke (" method" , std::vector<signalr::value>(), [&invoke_mre](const signalr::value&, std::exception_ptr exception )
842
+ hub_connection-> invoke (" method" , std::vector<signalr::value>(), [&invoke_mre](const signalr::value&, std::exception_ptr exception )
843
843
{
844
844
invoke_mre.set (exception );
845
845
});
@@ -882,7 +882,7 @@ TEST(stop, pending_callbacks_finished_if_hub_connections_goes_out_of_scope)
882
882
883
883
mre.get ();
884
884
885
- hub_connection. invoke (" method" , std::vector<signalr::value>(), [&invoke_mre](const signalr::value&, std::exception_ptr exception )
885
+ hub_connection-> invoke (" method" , std::vector<signalr::value>(), [&invoke_mre](const signalr::value&, std::exception_ptr exception )
886
886
{
887
887
invoke_mre.set (exception );
888
888
});
@@ -935,18 +935,18 @@ TEST(stop, stops_with_inprogress_negotiate)
935
935
936
936
auto disconnected_called = false ;
937
937
// disconnected not called for connections that never started successfully
938
- hub_connection. set_disconnected ([&disconnected_called](std::exception_ptr ex)
938
+ hub_connection-> set_disconnected ([&disconnected_called](std::exception_ptr ex)
939
939
{
940
940
disconnected_called = true ;
941
941
});
942
942
943
943
auto mre = manual_reset_event<void >();
944
- hub_connection. start ([&mre](std::exception_ptr exception )
944
+ hub_connection-> start ([&mre](std::exception_ptr exception )
945
945
{
946
946
mre.set (exception );
947
947
});
948
948
949
- hub_connection. stop ([&stop_mre](std::exception_ptr exception )
949
+ hub_connection-> stop ([&stop_mre](std::exception_ptr exception )
950
950
{
951
951
stop_mre.set (exception );
952
952
});
@@ -963,7 +963,7 @@ TEST(stop, stops_with_inprogress_negotiate)
963
963
// avoid AV from accessing stop_mre in callback
964
964
done_mre.get ();
965
965
966
- ASSERT_EQ (connection_state::disconnected, hub_connection. get_connection_state ());
966
+ ASSERT_EQ (connection_state::disconnected, hub_connection-> get_connection_state ());
967
967
ASSERT_FALSE (disconnected_called);
968
968
}
969
969
@@ -1770,12 +1770,12 @@ TEST(config, can_replace_scheduler)
1770
1770
signalr_client_config config{};
1771
1771
auto scheduler = std::make_shared<test_scheduler>();
1772
1772
config.set_scheduler (scheduler);
1773
- hub_connection. set_client_config (config);
1773
+ hub_connection-> set_client_config (config);
1774
1774
1775
1775
// do some "work" to verify scheduler is used
1776
1776
1777
1777
auto mre = manual_reset_event<void >();
1778
- hub_connection. start ([&mre](std::exception_ptr exception )
1778
+ hub_connection-> start ([&mre](std::exception_ptr exception )
1779
1779
{
1780
1780
mre.set (exception );
1781
1781
});
@@ -1787,7 +1787,7 @@ TEST(config, can_replace_scheduler)
1787
1787
mre.get ();
1788
1788
1789
1789
auto invoke_mre = manual_reset_event<void >();
1790
- hub_connection. invoke (" method" , std::vector<signalr::value>(), [&invoke_mre](const signalr::value& message, std::exception_ptr exception )
1790
+ hub_connection-> invoke (" method" , std::vector<signalr::value>(), [&invoke_mre](const signalr::value& message, std::exception_ptr exception )
1791
1791
{
1792
1792
if (exception )
1793
1793
{
@@ -1803,7 +1803,7 @@ TEST(config, can_replace_scheduler)
1803
1803
1804
1804
invoke_mre.get ();
1805
1805
1806
- hub_connection. stop ([&mre](std::exception_ptr ex)
1806
+ hub_connection-> stop ([&mre](std::exception_ptr ex)
1807
1807
{
1808
1808
mre.set ();
1809
1809
});
@@ -1911,10 +1911,10 @@ TEST(keepalive, sends_ping_messages)
1911
1911
[](std::function<void (std::exception_ptr)> callback) { callback (nullptr ); },
1912
1912
false );
1913
1913
auto hub_connection = create_hub_connection (websocket_client);
1914
- hub_connection. set_client_config (config);
1914
+ hub_connection-> set_client_config (config);
1915
1915
1916
1916
auto mre = manual_reset_event<void >();
1917
- hub_connection. start ([&mre](std::exception_ptr exception )
1917
+ hub_connection-> start ([&mre](std::exception_ptr exception )
1918
1918
{
1919
1919
mre.set (exception );
1920
1920
});
@@ -1931,7 +1931,7 @@ TEST(keepalive, sends_ping_messages)
1931
1931
ASSERT_EQ (" {\" protocol\" :\" json\" ,\" version\" :1}\x1e " , (*messages)[0 ]);
1932
1932
ASSERT_EQ (" {\" type\" :6}\x1e " , (*messages)[1 ]);
1933
1933
ASSERT_EQ (" {\" type\" :6}\x1e " , (*messages)[2 ]);
1934
- ASSERT_EQ (connection_state::connected, hub_connection. get_connection_state ());
1934
+ ASSERT_EQ (connection_state::connected, hub_connection-> get_connection_state ());
1935
1935
}
1936
1936
1937
1937
TEST (keepalive, server_timeout_on_no_ping_from_server)
@@ -1941,18 +1941,18 @@ TEST(keepalive, server_timeout_on_no_ping_from_server)
1941
1941
config.set_server_timeout (std::chrono::seconds (1 ));
1942
1942
auto websocket_client = create_test_websocket_client ();
1943
1943
auto hub_connection = create_hub_connection (websocket_client);
1944
- hub_connection. set_client_config (config);
1944
+ hub_connection-> set_client_config (config);
1945
1945
1946
1946
auto disconnected_called = false ;
1947
1947
1948
1948
auto disconnect_mre = manual_reset_event<void >();
1949
- hub_connection. set_disconnected ([&disconnected_called, &disconnect_mre](std::exception_ptr ex)
1949
+ hub_connection-> set_disconnected ([&disconnected_called, &disconnect_mre](std::exception_ptr ex)
1950
1950
{
1951
1951
disconnect_mre.set (ex);
1952
1952
});
1953
1953
1954
1954
auto mre = manual_reset_event<void >();
1955
- hub_connection. start ([&mre](std::exception_ptr exception )
1955
+ hub_connection-> start ([&mre](std::exception_ptr exception )
1956
1956
{
1957
1957
mre.set (exception );
1958
1958
});
@@ -1972,7 +1972,7 @@ TEST(keepalive, server_timeout_on_no_ping_from_server)
1972
1972
{
1973
1973
ASSERT_STREQ (" server timeout (1000 ms) elapsed without receiving a message from the server." , ex.what ());
1974
1974
}
1975
- ASSERT_EQ (connection_state::disconnected, hub_connection. get_connection_state ());
1975
+ ASSERT_EQ (connection_state::disconnected, hub_connection-> get_connection_state ());
1976
1976
}
1977
1977
1978
1978
TEST (keepalive, resets_server_timeout_timer_on_any_message_from_server)
@@ -1982,16 +1982,16 @@ TEST(keepalive, resets_server_timeout_timer_on_any_message_from_server)
1982
1982
config.set_server_timeout (std::chrono::seconds (1 ));
1983
1983
auto websocket_client = create_test_websocket_client ();
1984
1984
auto hub_connection = create_hub_connection (websocket_client);
1985
- hub_connection. set_client_config (config);
1985
+ hub_connection-> set_client_config (config);
1986
1986
1987
1987
auto disconnect_mre = manual_reset_event<void >();
1988
- hub_connection. set_disconnected ([&disconnect_mre](std::exception_ptr ex)
1988
+ hub_connection-> set_disconnected ([&disconnect_mre](std::exception_ptr ex)
1989
1989
{
1990
1990
disconnect_mre.set (ex);
1991
1991
});
1992
1992
1993
1993
auto mre = manual_reset_event<void >();
1994
- hub_connection. start ([&mre](std::exception_ptr exception )
1994
+ hub_connection-> start ([&mre](std::exception_ptr exception )
1995
1995
{
1996
1996
mre.set (exception );
1997
1997
});
@@ -2005,7 +2005,7 @@ TEST(keepalive, resets_server_timeout_timer_on_any_message_from_server)
2005
2005
std::this_thread::sleep_for (config.get_server_timeout () - std::chrono::milliseconds (500 ));
2006
2006
websocket_client->receive_message (" {\" type\" :6}\x1e " );
2007
2007
std::this_thread::sleep_for (std::chrono::seconds (1 ));
2008
- ASSERT_EQ (connection_state::connected, hub_connection. get_connection_state ());
2008
+ ASSERT_EQ (connection_state::connected, hub_connection-> get_connection_state ());
2009
2009
2010
2010
try
2011
2011
{
@@ -2016,5 +2016,5 @@ TEST(keepalive, resets_server_timeout_timer_on_any_message_from_server)
2016
2016
{
2017
2017
ASSERT_STREQ (" server timeout (1000 ms) elapsed without receiving a message from the server." , ex.what ());
2018
2018
}
2019
- ASSERT_EQ (connection_state::disconnected, hub_connection. get_connection_state ());
2019
+ ASSERT_EQ (connection_state::disconnected, hub_connection-> get_connection_state ());
2020
2020
}
0 commit comments