diff options
Diffstat (limited to 'src/components/transport_manager/src/tcp/tcp_connection_factory.cc')
-rw-r--r-- | src/components/transport_manager/src/tcp/tcp_connection_factory.cc | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/src/components/transport_manager/src/tcp/tcp_connection_factory.cc b/src/components/transport_manager/src/tcp/tcp_connection_factory.cc index 69173a0e0..7c6c06ddc 100644 --- a/src/components/transport_manager/src/tcp/tcp_connection_factory.cc +++ b/src/components/transport_manager/src/tcp/tcp_connection_factory.cc @@ -1,6 +1,5 @@ -/** - * - * Copyright (c) 2013, Ford Motor Company +/* + * Copyright (c) 2015, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,8 +40,9 @@ namespace transport_adapter { CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager") -TcpConnectionFactory::TcpConnectionFactory(TransportAdapterController* controller) - : controller_(controller) { +TcpConnectionFactory::TcpConnectionFactory( + TransportAdapterController* controller) + : controller_(controller) { } TransportAdapter::Error TcpConnectionFactory::Init() { @@ -50,19 +50,22 @@ TransportAdapter::Error TcpConnectionFactory::Init() { } TransportAdapter::Error TcpConnectionFactory::CreateConnection( - const DeviceUID& device_uid, const ApplicationHandle& app_handle) { - LOG4CXX_TRACE(logger_, "enter. DeviceUID: " << &device_uid << ", ApplicationHandle: " << - &app_handle); + const DeviceUID& device_uid, const ApplicationHandle& app_handle) { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG( + logger_, + "DeviceUID: " << &device_uid << ", ApplicationHandle: " << &app_handle); TcpServerOiginatedSocketConnection* connection( - new TcpServerOiginatedSocketConnection(device_uid, app_handle, - controller_)); - TransportAdapter::Error error = connection->Start(); - if (TransportAdapter::OK != error) { - LOG4CXX_ERROR(logger_, "Transport adapter error " << error); - delete connection; + new TcpServerOiginatedSocketConnection(device_uid, app_handle, + controller_)); + controller_->ConnectionCreated(connection, device_uid, app_handle); + if (connection->Start() == TransportAdapter::OK) { + LOG4CXX_DEBUG(logger_, "TCP connection initialised"); + return TransportAdapter::OK; + } else { + LOG4CXX_ERROR(logger_, "Could not initialise TCP connection"); + return TransportAdapter::FAIL; } - LOG4CXX_TRACE(logger_, "exit with error " << error); - return error; } void TcpConnectionFactory::Terminate() { |