HomebrewEvent - replacing pplx::event with a cross platform counterpart

This commit is contained in:
moozzyk 2015-08-03 22:58:41 -07:00
Родитель 7ae3d931f7
Коммит 0715d7ae76
12 изменённых файлов: 128 добавлений и 63 удалений

Просмотреть файл

@ -40,6 +40,7 @@
<ClInclude Include="..\..\connection_impl.h" />
<ClInclude Include="..\..\constants.h" />
<ClInclude Include="..\..\default_websocket_client.h" />
<ClInclude Include="..\..\event.h" />
<ClInclude Include="..\..\http_sender.h" />
<ClInclude Include="..\..\hub_connection_impl.h" />
<ClInclude Include="..\..\internal_hub_proxy.h" />

Просмотреть файл

@ -108,6 +108,9 @@
<ClInclude Include="..\..\case_insensitive_comparison_utils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\event.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\stdafx.cpp">

Просмотреть файл

@ -12,6 +12,7 @@
#include "transport_factory.h"
#include "logger.h"
#include "negotiation_response.h"
#include "event.h"
namespace signalr
{
@ -68,7 +69,7 @@ namespace signalr
pplx::cancellation_token_source m_disconnect_cts;
std::mutex m_stop_lock;
pplx::event m_start_completed_event;
event m_start_completed_event;
utility::string_t m_connection_token;
utility::string_t m_connection_data;
int m_reconnect_window; // in milliseconds

61
src/signalrclient/event.h Normal file
Просмотреть файл

@ -0,0 +1,61 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#pragma once
#include <mutex>
namespace signalr
{
class event
{
private:
std::mutex m_lock;
std::condition_variable m_condition;
bool m_signaled;
public:
static const unsigned int timeout_infinite = 0xFFFFFFFF;
event()
: m_signaled(false)
{
}
void set()
{
std::lock_guard<std::mutex> lock(m_lock);
m_signaled = true;
m_condition.notify_all();
}
void reset()
{
std::lock_guard<std::mutex> lock(m_lock);
m_signaled = false;
}
unsigned int wait(unsigned int timeout)
{
std::unique_lock<std::mutex> lock(m_lock);
if (timeout == event::timeout_infinite)
{
m_condition.wait(lock, [this]() { return m_signaled; });
return 0;
}
else
{
std::chrono::milliseconds period(timeout);
auto status = m_condition.wait_for(lock, period, [this]() { return m_signaled; });
_ASSERTE(status == m_signaled);
// Return 0 if the wait completed as a result of signaling the event. Otherwise, return timeout_infinite
return status ? 0 : event::timeout_infinite;
}
}
unsigned int wait()
{
return wait(event::timeout_infinite);
}
};
}

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#pragma once;
#pragma once
#include "pplx/pplxtasks.h"
#include "cpprest/base_uri.h"

Просмотреть файл

@ -30,7 +30,7 @@ TEST(connection_tests, send_message)
{
auto conn = std::make_shared<signalr::connection>(url + U("raw-connection"));
auto message = std::make_shared<utility::string_t>();
auto received_event = std::make_shared<pplx::event>();
auto received_event = std::make_shared<signalr::event>();
conn->set_message_received([message, received_event](const utility::string_t& payload)
{
@ -56,7 +56,7 @@ TEST(connection_tests, send_message_after_connection_restart)
{
auto conn = std::make_shared<signalr::connection>(url + U("raw-connection"));
auto message = std::make_shared<utility::string_t>();
auto received_event = std::make_shared<pplx::event>();
auto received_event = std::make_shared<signalr::event>();
conn->set_message_received([message, received_event](const utility::string_t& payload)
{

Просмотреть файл

@ -16,8 +16,8 @@ TEST(hub_connection_tests, connection_status_start_stop_start_reconnect)
{
auto hub_conn = std::make_shared<signalr::hub_connection>(url);
auto weak_hub_conn = std::weak_ptr<signalr::hub_connection>(hub_conn);
auto reconnecting_event = std::make_shared<pplx::event>();
auto reconnected_event = std::make_shared<pplx::event>();
auto reconnecting_event = std::make_shared<signalr::event>();
auto reconnected_event = std::make_shared<signalr::event>();
auto hub_proxy = hub_conn->create_hub_proxy(U("hubConnection"));
@ -66,7 +66,7 @@ TEST(hub_connection_tests, send_message)
{
auto hub_conn = std::make_shared<signalr::hub_connection>(url + U("custom"), U(""), signalr::trace_level::all, nullptr, false);
auto message = std::make_shared<utility::string_t>();
auto received_event = std::make_shared<pplx::event>();
auto received_event = std::make_shared<signalr::event>();
auto hub_proxy = hub_conn->create_hub_proxy(U("hubConnection"));
@ -112,7 +112,7 @@ TEST(hub_connection_tests, send_message_after_connection_restart)
{
auto hub_conn = std::make_shared<signalr::hub_connection>(url);
auto message = std::make_shared<utility::string_t>();
auto received_event = std::make_shared<pplx::event>();
auto received_event = std::make_shared<signalr::event>();
auto hub_proxy = hub_conn->create_hub_proxy(U("hubConnection"));
@ -144,8 +144,8 @@ TEST(hub_connection_tests, send_message_after_reconnect)
{
auto hub_conn = std::make_shared<signalr::hub_connection>(url);
auto message = std::make_shared<utility::string_t>();
auto reconnected_event = std::make_shared<pplx::event>();
auto received_event = std::make_shared<pplx::event>();
auto reconnected_event = std::make_shared<signalr::event>();
auto received_event = std::make_shared<signalr::event>();
auto hub_proxy = hub_conn->create_hub_proxy(U("hubConnection"));
@ -186,7 +186,7 @@ TEST(hub_connection_tests, send_message_empty_param)
{
auto hub_conn = std::make_shared<signalr::hub_connection>(url);
auto message = std::make_shared<utility::string_t>();
auto received_event = std::make_shared<pplx::event>();
auto received_event = std::make_shared<signalr::event>();
auto hub_proxy = hub_conn->create_hub_proxy(U("hubConnection"));
@ -211,7 +211,7 @@ TEST(hub_connection_tests, send_message_primitive_params)
{
auto hub_conn = std::make_shared<signalr::hub_connection>(url);
auto message = std::make_shared<utility::string_t>();
auto received_event = std::make_shared<pplx::event>();
auto received_event = std::make_shared<signalr::event>();
auto hub_proxy = hub_conn->create_hub_proxy(U("hubConnection"));
@ -249,7 +249,7 @@ TEST(hub_connection_tests, send_message_complex_type)
{
auto hub_conn = std::make_shared<signalr::hub_connection>(url);
auto message = std::make_shared<utility::string_t>();
auto received_event = std::make_shared<pplx::event>();
auto received_event = std::make_shared<signalr::event>();
auto hub_proxy = hub_conn->create_hub_proxy(U("hubConnection"));

Просмотреть файл

@ -8,4 +8,5 @@
#define NOMINMAX
#endif
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include "../../src/signalrclient/event.h"

Просмотреть файл

@ -463,7 +463,7 @@ TEST(connection_impl_set_message_received, callback_invoked_when_message_receive
auto message = std::make_shared<utility::string_t>();
auto message_received_event = std::make_shared<pplx::event>();
auto message_received_event = std::make_shared<event>();
connection->set_message_received_string([message, message_received_event](const utility::string_t &m){
if (m == _XPLATSTR("\"Test\""))
{
@ -505,7 +505,7 @@ TEST(connection_impl_set_message_received, exception_from_callback_caught_and_lo
std::shared_ptr<log_writer> writer(std::make_shared<memory_log_writer>());
auto connection = create_connection(websocket_client, writer, trace_level::errors);
auto message_received_event = std::make_shared<pplx::event>();
auto message_received_event = std::make_shared<event>();
connection->set_message_received_string([message_received_event](const utility::string_t &m){
if (m == _XPLATSTR("\"throw\""))
{
@ -551,7 +551,7 @@ TEST(connection_impl_set_message_received, non_std_exception_from_callback_caugh
std::shared_ptr<log_writer> writer(std::make_shared<memory_log_writer>());
auto connection = create_connection(websocket_client, writer, trace_level::errors);
auto message_received_event = std::make_shared<pplx::event>();
auto message_received_event = std::make_shared<event>();
connection->set_message_received_string([message_received_event](const utility::string_t &m)
{
if (m == _XPLATSTR("\"throw\""))
@ -598,7 +598,7 @@ TEST(connection_impl_set_message_received, error_logged_for_malformed_payload)
std::shared_ptr<log_writer> writer(std::make_shared<memory_log_writer>());
auto connection = create_connection(websocket_client, writer, trace_level::errors);
auto message_received_event = std::make_shared<pplx::event>();
auto message_received_event = std::make_shared<event>();
connection->set_message_received_string([message_received_event](const utility::string_t&)
{
// this is called only once because we have just one response with a message
@ -638,7 +638,7 @@ TEST(connection_impl_set_message_received, unexpected_responses_logged)
std::shared_ptr<log_writer> writer(std::make_shared<memory_log_writer>());
auto connection = create_connection(websocket_client, writer, trace_level::info);
auto message_received_event = std::make_shared<pplx::event>();
auto message_received_event = std::make_shared<event>();
connection->set_message_received_string([message_received_event](const utility::string_t&)
{
// this is called only once because we have just one response with a message
@ -733,7 +733,7 @@ TEST(connection_impl_stop, stopping_disconnected_connection_is_no_op)
TEST(connection_impl_stop, stopping_disconnecting_connection_returns_cancelled_task)
{
pplx::event close_event;
event close_event;
auto writer = std::shared_ptr<log_writer>{std::make_shared<memory_log_writer>()};
auto websocket_client = create_test_websocket_client(
@ -870,7 +870,7 @@ TEST(connection_impl_stop, dtor_stops_the_connection)
TEST(connection_impl_stop, stop_cancels_ongoing_start_request)
{
auto disconnect_completed_event = std::make_shared<pplx::event>();
auto disconnect_completed_event = std::make_shared<event>();
auto websocket_client = create_test_websocket_client(
/* receive function */ [disconnect_completed_event]()
@ -1146,7 +1146,7 @@ TEST(connection_impl_reconnect, can_reconnect)
auto connection = create_connection(websocket_client);
connection->set_reconnect_delay(100);
auto reconnected_event = std::make_shared<pplx::event>();
auto reconnected_event = std::make_shared<event>();
connection->set_reconnected([reconnected_event](){ reconnected_event->set(); });
connection->start();
@ -1178,7 +1178,7 @@ TEST(connection_impl_reconnect, successful_reconnect_state_changes)
std::shared_ptr<log_writer> writer(std::make_shared<memory_log_writer>());
auto connection = create_connection(websocket_client, writer, trace_level::state_changes);
connection->set_reconnect_delay(100);
auto reconnected_event = std::make_shared<pplx::event>();
auto reconnected_event = std::make_shared<event>();
connection->set_reconnected([reconnected_event](){ reconnected_event->set(); });
connection->start();
@ -1244,7 +1244,7 @@ TEST(connection_impl_reconnect, connection_stopped_if_reconnecting_failed)
connection_impl::create(create_uri(), _XPLATSTR(""), trace_level::state_changes,
writer, std::move(web_request_factory), std::make_unique<test_transport_factory>(websocket_client));
auto disconnected_event = std::make_shared<pplx::event>();
auto disconnected_event = std::make_shared<event>();
connection->set_disconnected([disconnected_event](){ disconnected_event->set(); });
connection->set_reconnect_delay(100);
connection->start();
@ -1264,7 +1264,7 @@ TEST(connection_impl_reconnect, connection_stopped_if_reconnecting_failed)
TEST(connection_impl_reconnect, reconnect_works_if_connection_dropped_during_after_init_and_before_start_successfully_completed)
{
auto connection_dropped_event = std::make_shared<pplx::event>();
auto connection_dropped_event = std::make_shared<event>();
int call_number = -1;
auto websocket_client = create_test_websocket_client(
@ -1291,7 +1291,7 @@ TEST(connection_impl_reconnect, reconnect_works_if_connection_dropped_during_aft
std::shared_ptr<log_writer> writer(std::make_shared<memory_log_writer>());
auto connection = create_connection(websocket_client, writer, trace_level::state_changes);
connection->set_reconnect_delay(100);
auto reconnected_event = std::make_shared<pplx::event>();
auto reconnected_event = std::make_shared<event>();
connection->set_reconnected([reconnected_event](){ reconnected_event->set(); });
connection->start();
@ -1308,7 +1308,7 @@ TEST(connection_impl_reconnect, reconnect_works_if_connection_dropped_during_aft
TEST(connection_impl_reconnect, reconnect_cancelled_if_connection_dropped_during_start_and_start_failed)
{
auto connection_dropped_event = std::make_shared<pplx::event>();
auto connection_dropped_event = std::make_shared<event>();
auto web_request_factory = std::make_unique<test_web_request_factory>([&connection_dropped_event](const web::uri& url)
{
@ -1428,7 +1428,7 @@ TEST(connection_impl_reconnect, reconnect_cancelled_when_connection_being_stoppe
std::shared_ptr<log_writer> writer(std::make_shared<memory_log_writer>());
auto connection = create_connection(websocket_client, writer, trace_level::all);
connection->set_reconnect_delay(100);
pplx::event reconnecting_event{};
event reconnecting_event{};
connection->set_reconnecting([&reconnecting_event](){ reconnecting_event.set(); });
connection->start().then([&connection_started](){ connection_started = true; });
@ -1502,7 +1502,7 @@ TEST(connection_impl_reconnect, reconnect_cancelled_if_connection_goes_out_of_sc
{
auto connection = create_connection(websocket_client, writer, trace_level::state_changes);
connection->set_reconnect_delay(100);
pplx::event reconnecting_event{};
event reconnecting_event{};
connection->set_reconnecting([&reconnecting_event](){ reconnecting_event.set(); });
connection->start().then([&connection_started](){ connection_started = true; });
@ -1552,7 +1552,7 @@ TEST(connection_impl_reconnect, std_exception_for_reconnected_reconnecting_callb
auto connection = create_connection(websocket_client, writer, trace_level::errors);
connection->set_reconnect_delay(100);
connection->set_reconnecting([](){ throw std::runtime_error("exception from reconnecting"); });
auto reconnected_event = std::make_shared<pplx::event>();
auto reconnected_event = std::make_shared<event>();
connection->set_reconnected([reconnected_event]()
{
reconnected_event->set();
@ -1599,7 +1599,7 @@ TEST(connection_impl_reconnect, exception_for_reconnected_reconnecting_callback_
auto connection = create_connection(websocket_client, writer, trace_level::errors);
connection->set_reconnect_delay(100);
connection->set_reconnecting([](){ throw 42; });
auto reconnected_event = std::make_shared<pplx::event>();
auto reconnected_event = std::make_shared<event>();
connection->set_reconnected([reconnected_event]()
{
reconnected_event->set();
@ -1672,7 +1672,7 @@ TEST(connection_impl_reconnect, can_stop_connection_from_reconnecting_event)
connection_impl::create(create_uri(), _XPLATSTR(""), trace_level::state_changes,
writer, std::move(web_request_factory), std::make_unique<test_transport_factory>(websocket_client));
auto stop_event = std::make_shared<pplx::event>();
auto stop_event = std::make_shared<event>();
connection->set_reconnecting([&connection, stop_event]()
{
connection->stop()
@ -1756,7 +1756,7 @@ TEST(connection_impl_reconnect, current_reconnect_cancelled_if_another_reconnect
}
});
pplx::event reconnected_event;
event reconnected_event;
connection->set_reconnected([&reconnected_event]()
{
reconnected_event.set();

Просмотреть файл

@ -335,7 +335,7 @@ TEST(hub_invocation, hub_connection_invokes_users_code_on_hub_invocations)
auto hub_proxy = hub_connection->create_hub_proxy(_XPLATSTR("MY_hub"));
auto payload = std::make_shared<utility::string_t>();
auto on_broadcast_event = std::make_shared<pplx::event>();
auto on_broadcast_event = std::make_shared<event>();
hub_proxy->on(_XPLATSTR("broadCAST"), [on_broadcast_event, payload](const json::value& message)
{
*payload = message.serialize();
@ -371,7 +371,7 @@ TEST(hub_invocation, hub_connection_discards_persistent_connection_message_primi
auto hub_connection = create_hub_connection(websocket_client, writer, trace_level::info);
auto hub_proxy = hub_connection->create_hub_proxy(_XPLATSTR("my_hub"));
auto on_broadcast_event = std::make_shared<pplx::event>();
auto on_broadcast_event = std::make_shared<event>();
hub_proxy->on(_XPLATSTR("broadcast"), [on_broadcast_event](const json::value&)
{
on_broadcast_event->set();
@ -411,7 +411,7 @@ TEST(hub_invocation, hub_connection_invokes_persistent_connection_message_object
auto hub_connection = create_hub_connection(websocket_client, writer, trace_level::info);
auto hub_proxy = hub_connection->create_hub_proxy(_XPLATSTR("my_hub"));
auto on_broadcast_event = std::make_shared<pplx::event>();
auto on_broadcast_event = std::make_shared<event>();
hub_proxy->on(_XPLATSTR("broadcast"), [on_broadcast_event](const json::value&)
{
on_broadcast_event->set();
@ -484,7 +484,7 @@ TEST(hub_invocation, hub_connection_logs_if_no_hub_for_invocation)
{
int call_number = -1;
auto done_event = std::make_shared<pplx::event>();
auto done_event = std::make_shared<event>();
auto websocket_client = create_test_websocket_client(
/* receive function */ [call_number, done_event]()
@ -522,7 +522,7 @@ TEST(hub_invocation, hub_connection_logs_if_no_hub_for_invocation)
TEST(invoke_json, invoke_returns_value_returned_from_the_server)
{
auto callback_registered_event = std::make_shared<pplx::event>();
auto callback_registered_event = std::make_shared<event>();
int call_number = -1;
auto websocket_client = create_test_websocket_client(
@ -560,7 +560,7 @@ TEST(invoke_json, invoke_returns_value_returned_from_the_server)
TEST(invoke_json, invoke_propagates_errors_from_server_as_exceptions)
{
auto callback_registered_event = std::make_shared<pplx::event>();
auto callback_registered_event = std::make_shared<event>();
int call_number = -1;
auto websocket_client = create_test_websocket_client(
@ -604,7 +604,7 @@ TEST(invoke_json, invoke_propagates_errors_from_server_as_exceptions)
TEST(invoke_json, invoke_propagates_hub_errors_from_server_as_hub_exceptions)
{
auto callback_registered_event = std::make_shared<pplx::event>();
auto callback_registered_event = std::make_shared<event>();
int call_number = -1;
auto websocket_client = create_test_websocket_client(
@ -649,7 +649,7 @@ TEST(invoke_json, invoke_propagates_hub_errors_from_server_as_hub_exceptions)
TEST(progress, progress_callback_called_for_progress_messages_json)
{
auto callback_registered_event = std::make_shared<pplx::event>();
auto callback_registered_event = std::make_shared<event>();
int call_number = -1;
auto websocket_client = create_test_websocket_client(
@ -695,7 +695,7 @@ TEST(progress, progress_callback_called_for_progress_messages_json)
TEST(invoke_void, invoke_unblocks_task_when_server_completes_call)
{
auto callback_registered_event = std::make_shared<pplx::event>();
auto callback_registered_event = std::make_shared<event>();
int call_number = -1;
auto websocket_client = create_test_websocket_client(
@ -733,7 +733,7 @@ TEST(invoke_void, invoke_unblocks_task_when_server_completes_call)
TEST(invoke_void, invoke_logs_if_callback_for_given_id_not_found)
{
auto message_received_event = std::make_shared<pplx::event>();
auto message_received_event = std::make_shared<event>();
int call_number = -1;
auto websocket_client = create_test_websocket_client(
@ -771,7 +771,7 @@ TEST(invoke_void, invoke_logs_if_callback_for_given_id_not_found)
TEST(invoke_void, invoke_propagates_errors_from_server_as_exceptions)
{
auto callback_registered_event = std::make_shared<pplx::event>();
auto callback_registered_event = std::make_shared<event>();
int call_number = -1;
auto websocket_client = create_test_websocket_client(
@ -815,7 +815,7 @@ TEST(invoke_void, invoke_propagates_errors_from_server_as_exceptions)
TEST(invoke_void, invoke_propagates_hub_errors_from_server_as_hub_exceptions)
{
auto callback_registered_event = std::make_shared<pplx::event>();
auto callback_registered_event = std::make_shared<event>();
int call_number = -1;
auto websocket_client = create_test_websocket_client(
@ -860,7 +860,7 @@ TEST(invoke_void, invoke_propagates_hub_errors_from_server_as_hub_exceptions)
TEST(invoke_void, invoke_creates_hub_exception_even_if_no_error_data)
{
auto callback_registered_event = std::make_shared<pplx::event>();
auto callback_registered_event = std::make_shared<event>();
int call_number = -1;
auto websocket_client = create_test_websocket_client(
@ -905,7 +905,7 @@ TEST(invoke_void, invoke_creates_hub_exception_even_if_no_error_data)
TEST(invoke_void, invoke_creates_runtime_error_when_hub_exception_indicator_false)
{
auto callback_registered_event = std::make_shared<pplx::event>();
auto callback_registered_event = std::make_shared<event>();
int call_number = -1;
auto websocket_client = create_test_websocket_client(
@ -950,7 +950,7 @@ TEST(invoke_void, invoke_creates_runtime_error_when_hub_exception_indicator_fals
TEST(invoke_void, invoke_creates_runtime_error_even_hub_exception_indicator_non_bool)
{
auto callback_registered_event = std::make_shared<pplx::event>();
auto callback_registered_event = std::make_shared<event>();
int call_number = -1;
auto websocket_client = create_test_websocket_client(
@ -995,7 +995,7 @@ TEST(invoke_void, invoke_creates_runtime_error_even_hub_exception_indicator_non_
TEST(progress, progress_callback_called_for_progress_messages)
{
auto callback_registered_event = std::make_shared<pplx::event>();
auto callback_registered_event = std::make_shared<event>();
int call_number = -1;
auto websocket_client = create_test_websocket_client(
@ -1041,7 +1041,7 @@ TEST(progress, progress_callback_called_for_progress_messages)
TEST(progress, exceptions_from_progress_callbacks_logged)
{
auto callback_registered_event = std::make_shared<pplx::event>();
auto callback_registered_event = std::make_shared<event>();
int call_number = -1;
auto websocket_client = create_test_websocket_client(
@ -1091,7 +1091,7 @@ TEST(progress, exceptions_from_progress_callbacks_logged)
TEST(reconnect, pending_invocations_finished_if_connection_lost)
{
auto message_sent_event = std::make_shared<pplx::event>();
auto message_sent_event = std::make_shared<event>();
auto init_sent = false;
auto websocket_client = create_test_websocket_client(
@ -1119,7 +1119,7 @@ TEST(reconnect, pending_invocations_finished_if_connection_lost)
auto hub_connection = create_hub_connection(websocket_client);
auto test_completed_event = std::make_shared<pplx::event>();
auto test_completed_event = std::make_shared<event>();
hub_connection->start()
.then([hub_connection, message_sent_event, test_completed_event]()
{
@ -1145,7 +1145,7 @@ TEST(reconnect, pending_invocations_finished_if_connection_lost)
TEST(reconnect, pending_invocations_finished_and_custom_reconnecting_callback_invoked_if_connection_lost)
{
auto message_sent_event = std::make_shared<pplx::event>();
auto message_sent_event = std::make_shared<event>();
auto init_sent = false;
auto websocket_client = create_test_websocket_client(
@ -1172,7 +1172,7 @@ TEST(reconnect, pending_invocations_finished_and_custom_reconnecting_callback_in
});
auto hub_connection = create_hub_connection(websocket_client);
auto reconnecting_invoked_event = std::make_shared<pplx::event >();
auto reconnecting_invoked_event = std::make_shared<event >();
hub_connection->set_reconnecting([reconnecting_invoked_event](){ reconnecting_invoked_event->set(); });
hub_connection->start()
@ -1227,7 +1227,7 @@ TEST(reconnect, reconnecting_reconnected_callbacks_invoked)
auto reconnecting_invoked = false;
hub_connection->set_reconnecting([&reconnecting_invoked](){ reconnecting_invoked = true; });
auto reconnected_event = std::make_shared<pplx::event>();
auto reconnected_event = std::make_shared<event>();
hub_connection->set_reconnected([reconnected_event]() { reconnected_event->set(); });
hub_connection->start();

Просмотреть файл

@ -8,9 +8,7 @@
#define NOMINMAX
#endif
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include "../../src/signalrclient/event.h"

Просмотреть файл

@ -292,7 +292,7 @@ TEST(websocket_transport_disconnect, exceptions_from_outstanding_receive_task_ob
{
auto client = std::make_shared<test_websocket_client>();
auto receive_event = std::make_shared<pplx::event>();
auto receive_event = std::make_shared<event>();
client->set_receive_function([receive_event]()
{
return pplx::create_task([receive_event]()
@ -343,7 +343,7 @@ TEST(websocket_transport_receive_loop, receive_loop_logs_std_exception)
template<typename T>
void receive_loop_logs_exception_runner(const T& e, const utility::string_t& expected_message, trace_level trace_level)
{
pplx::event receive_event;
event receive_event;
auto client = std::make_shared<test_websocket_client>();
client->set_receive_function([&receive_event, &e]()->pplx::task<std::string>
@ -381,7 +381,7 @@ TEST(websocket_transport_receive_loop, process_response_callback_called_when_mes
return pplx::task_from_result(std::string("msg"));
});
auto process_response_event = std::make_shared<pplx::event>();
auto process_response_event = std::make_shared<event>();
auto msg = std::make_shared<utility::string_t>();
auto process_response = [msg, process_response_event](const utility::string_t& message)
@ -415,7 +415,7 @@ TEST(websocket_transport_receive_loop, error_callback_called_when_exception_thro
return pplx::task_from_result();
});
auto error_event = std::make_shared<pplx::event>();
auto error_event = std::make_shared<event>();
auto exception_msg = std::make_shared<std::string>();
auto error_callback = [exception_msg, error_event](const std::exception& e)