Disconnected - adding connection_state.

This commit is contained in:
Pawel Kadluczka 2014-10-31 16:11:01 -07:00
Родитель 567a9431e4
Коммит 3c5d449a70
10 изменённых файлов: 61 добавлений и 1 удалений

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

@ -8,6 +8,7 @@
#include "transport_type.h"
#include "web_request_factory.h"
#include "transport_factory.h"
#include "connection_state.h"
namespace signalr
{
@ -26,6 +27,8 @@ namespace signalr
SIGNALRCLIENT_API pplx::task<void> start();
SIGNALRCLIENT_API connection_state get_connection_state() const;
private:
web_request_factory m_web_request_factory;
transport_factory m_transport_factory;

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

@ -0,0 +1,15 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#pragma once
namespace signalr
{
enum class connection_state
{
connecting,
connected,
reconnecting,
disconnected
};
}

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

@ -89,6 +89,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\include\signalrclient\connection.h" />
<ClInclude Include="..\..\..\..\include\signalrclient\connection_state.h" />
<ClInclude Include="..\..\..\..\include\signalrclient\trace_level.h" />
<ClInclude Include="..\..\..\..\include\signalrclient\transport.h" />
<ClInclude Include="..\..\..\..\include\signalrclient\transport_factory.h" />

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

@ -72,6 +72,9 @@
<ClInclude Include="..\..\..\..\include\signalrclient\web_response.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\signalrclient\connection_state.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\stdafx.cpp">

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

@ -24,5 +24,10 @@ namespace signalr
{
return m_pImpl->start();
}
connection_state connection::get_connection_state() const
{
return m_pImpl->get_connection_state();
}
}

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

@ -8,11 +8,17 @@ namespace signalr
{
connection_impl::connection_impl(const utility::string_t& url, const utility::string_t& querystring,
web_request_factory& web_request_factory, transport_factory& transport_factory)
: m_base_uri(url), m_querystring(querystring), m_web_request_factory(web_request_factory), m_transport_factory(transport_factory)
: m_base_uri(url), m_querystring(querystring), m_web_request_factory(web_request_factory),
m_transport_factory(transport_factory), m_connection_state(connection_state::disconnected)
{ }
pplx::task<void> connection_impl::start()
{
return pplx::task_from_result();
}
connection_state connection_impl::get_connection_state() const
{
return m_connection_state;
}
}

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

@ -6,6 +6,7 @@
#include <cpprest\http_client.h>
#include "signalrclient\web_request_factory.h"
#include "signalrclient\transport_factory.h"
#include "signalrclient\connection_state.h"
namespace signalr
{
@ -23,9 +24,12 @@ namespace signalr
pplx::task<void> start();
connection_state get_connection_state() const;
private:
web::uri m_base_uri;
utility::string_t m_querystring;
connection_state m_connection_state;
web_request_factory &m_web_request_factory;
transport_factory& m_transport_factory;

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

@ -92,6 +92,7 @@
<ClInclude Include="..\..\web_request_stub.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\connection_impl_tests.cpp" />
<ClCompile Include="..\..\http_sender_tests.cpp" />
<ClCompile Include="..\..\request_sender_tests.cpp" />
<ClCompile Include="..\..\signalrclienttests.cpp" />

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

@ -62,6 +62,9 @@
<ClCompile Include="..\..\test_websocket_client.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\connection_impl_tests.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

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

@ -0,0 +1,19 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#include "stdafx.h"
#include "connection_impl.h"
#include "signalrclient\web_request_factory.h"
#include "signalrclient\transport_factory.h"
using namespace signalr;
TEST(connection_impl_connection_state, initial_connection_state_is_disconnected)
{
web_request_factory request_factory;
transport_factory transport_factory;
ASSERT_EQ(
connection_state::disconnected,
connection_impl(_XPLATSTR("url"), _XPLATSTR(""), request_factory, transport_factory).get_connection_state());
}