From b0b1c52ead4d9178d0393f0f2c6ebd2b75703f8d Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Thu, 13 Feb 2020 13:58:41 +0200 Subject: Rename WebSocketTransport adapter to WebSocketServerTransportAdapter --- .../websocket_server_transport_adapter.h | 115 +++++++++++++++++++++ .../websocket_server/websocket_transport_adapter.h | 115 --------------------- .../src/transport_manager_default.cc | 4 +- .../websocket_server_transport_adapter.cc | 97 +++++++++++++++++ .../websocket_transport_adapter.cc | 97 ----------------- 5 files changed, 214 insertions(+), 214 deletions(-) create mode 100644 src/components/transport_manager/include/transport_manager/websocket_server/websocket_server_transport_adapter.h delete mode 100644 src/components/transport_manager/include/transport_manager/websocket_server/websocket_transport_adapter.h create mode 100644 src/components/transport_manager/src/websocket_server/websocket_server_transport_adapter.cc delete mode 100644 src/components/transport_manager/src/websocket_server/websocket_transport_adapter.cc diff --git a/src/components/transport_manager/include/transport_manager/websocket_server/websocket_server_transport_adapter.h b/src/components/transport_manager/include/transport_manager/websocket_server/websocket_server_transport_adapter.h new file mode 100644 index 0000000000..28e4436605 --- /dev/null +++ b/src/components/transport_manager/include/transport_manager/websocket_server/websocket_server_transport_adapter.h @@ -0,0 +1,115 @@ +/* + * \file websocket_transport_adapter.h + * \brief WebSocketTransportAdapter class header file. + * + * Copyright (c) 2020, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_WEBSOCKET_SERVER_WEBSOCKET_SERVER_TRANSPORT_ADAPTER_H_ +#define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_WEBSOCKET_SERVER_WEBSOCKET_SERVER_TRANSPORT_ADAPTER_H_ + +#include "transport_manager/transport_adapter/transport_adapter_impl.h" + +namespace transport_manager { +namespace transport_adapter { + +/** + * @brief Transport adapter that uses WebSocket transport. + */ +class WebSocketServerTransportAdapter : public TransportAdapterImpl { + public: + /** + * @brief Constructor. + */ + WebSocketServerTransportAdapter(resumption::LastState& last_state, + const TransportManagerSettings& settings); + + /** + * @brief Destructor. + */ + virtual ~WebSocketServerTransportAdapter(); + + /** + * @brief Websocket server transport adapter + * specific Init() method + * @note Perform additional actions required by WS transport adapter + * then calls basic class Init() + */ + TransportAdapter::Error Init() OVERRIDE; + + /** + * @brief Adds webengine device to internal storage + * of related WebSocket transport adapter + * @param device webengine device to add + * @note webengine device storage required + * to be used in Low Voltage conditions + */ + DeviceSptr AddDevice(DeviceSptr device) OVERRIDE; + + /** + * @brief Notification that transport's configuration is updated + * + * @param new_config The new configuration of the transport + */ + void TransportConfigUpdated(const TransportConfig& new_config) OVERRIDE; + + /** + * @brief Returns the transport's configuration information + */ + virtual TransportConfig GetTransportConfiguration() const OVERRIDE; + + protected: + /** + * @brief Return type of device. + * + * @return String with device type. + */ + DeviceType GetDeviceType() const OVERRIDE; + + private: + /** + * @brief Keeps transport specific configuration + * + * TCP transport uses following information: + * - "enabled": whether the transport is currently enabled or not. Value can + * be "true" or "false". + * - "tcp_ip_address": string representation of IP address (either IPv4 or + * IPv6) + * - "tcp_port": string representation of TCP port number (e.g. "12345") + */ + TransportConfig transport_config_; + DeviceSptr webengine_device_; +}; + +} // namespace transport_adapter +} // namespace transport_manager + +#endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_WEBSOCKET_SERVER_WEBSOCKET_SERVER_TRANSPORT_ADAPTER_H_ diff --git a/src/components/transport_manager/include/transport_manager/websocket_server/websocket_transport_adapter.h b/src/components/transport_manager/include/transport_manager/websocket_server/websocket_transport_adapter.h deleted file mode 100644 index 912cdda277..0000000000 --- a/src/components/transport_manager/include/transport_manager/websocket_server/websocket_transport_adapter.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * \file websocket_transport_adapter.h - * \brief WebSocketTransportAdapter class header file. - * - * Copyright (c) 2020, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_WEBSOCKET_SERVER_WEBSOCKET_TRANSPORT_ADAPTER_H_ -#define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_WEBSOCKET_SERVER_WEBSOCKET_TRANSPORT_ADAPTER_H_ - -#include "transport_manager/transport_adapter/transport_adapter_impl.h" - -namespace transport_manager { -namespace transport_adapter { - -/** - * @brief Transport adapter that uses WebSocket transport. - */ -class WebSocketTransportAdapter : public TransportAdapterImpl { - public: - /** - * @brief Constructor. - */ - explicit WebSocketTransportAdapter(resumption::LastState& last_state, - const TransportManagerSettings& settings); - - /** - * @brief Destructor. - */ - virtual ~WebSocketTransportAdapter(); - - /** - * @brief Websocket transport adapter - * specific Init() method - * @note Perform additional actions required by WS transport adapter - * then calls basic class Init() - */ - TransportAdapter::Error Init() OVERRIDE; - - /** - * @brief Adds webengine device to internal storage - * of related WebSocket transport adapter - * @param device webengine device to add - * @note webengine device storage required - * to be used in Low Voltage conditions - */ - DeviceSptr AddDevice(DeviceSptr device) OVERRIDE; - - /** - * @brief Notification that transport's configuration is updated - * - * @param new_config The new configuration of the transport - */ - void TransportConfigUpdated(const TransportConfig& new_config) OVERRIDE; - - /** - * @brief Returns the transport's configuration information - */ - virtual TransportConfig GetTransportConfiguration() const OVERRIDE; - - protected: - /** - * @brief Return type of device. - * - * @return String with device type. - */ - DeviceType GetDeviceType() const OVERRIDE; - - private: - /** - * @brief Keeps transport specific configuration - * - * TCP transport uses following information: - * - "enabled": whether the transport is currently enabled or not. Value can - * be "true" or "false". - * - "tcp_ip_address": string representation of IP address (either IPv4 or - * IPv6) - * - "tcp_port": string representation of TCP port number (e.g. "12345") - */ - TransportConfig transport_config_; - DeviceSptr webengine_device_; -}; - -} // namespace transport_adapter -} // namespace transport_manager - -#endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_WEBSOCKET_SERVER_WEBSOCKET_TRANSPORT_ADAPTER_H_ diff --git a/src/components/transport_manager/src/transport_manager_default.cc b/src/components/transport_manager/src/transport_manager_default.cc index 2d6f1769cb..0a8289253f 100644 --- a/src/components/transport_manager/src/transport_manager_default.cc +++ b/src/components/transport_manager/src/transport_manager_default.cc @@ -49,7 +49,7 @@ #endif // CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT #ifdef WEBSOCKET_SERVER_TRANSPORT_SUPPORT -#include "transport_manager/websocket_server/websocket_transport_adapter.h" +#include "transport_manager/websocket_server/websocket_server_transport_adapter.h" #endif #if defined(BUILD_TESTS) @@ -144,7 +144,7 @@ int TransportManagerDefault::Init(resumption::LastState& last_state) { #endif // CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT #ifdef WEBSOCKET_SERVER_TRANSPORT_SUPPORT - auto ta_websocket = new transport_adapter::WebSocketTransportAdapter( + auto ta_websocket = new transport_adapter::WebSocketServerTransportAdapter( last_state, get_settings()); #ifdef TELEMETRY_MONITOR if (metric_observer_) { diff --git a/src/components/transport_manager/src/websocket_server/websocket_server_transport_adapter.cc b/src/components/transport_manager/src/websocket_server/websocket_server_transport_adapter.cc new file mode 100644 index 0000000000..2983d1db9a --- /dev/null +++ b/src/components/transport_manager/src/websocket_server/websocket_server_transport_adapter.cc @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2020, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "transport_manager/websocket_server/websocket_server_transport_adapter.h" + +#include +#include +#include +#include + +#include +#include + +#include "transport_manager/websocket_server/websocket_listener.h" +#include "utils/logger.h" +#include "utils/threads/thread_delegate.h" + +namespace transport_manager { +namespace transport_adapter { + +CREATE_LOGGERPTR_GLOBAL(logger_, "WebSocketTransportAdapter") + +WebSocketServerTransportAdapter::WebSocketServerTransportAdapter( + resumption::LastState& last_state, const TransportManagerSettings& settings) + : TransportAdapterImpl(nullptr, + nullptr, + new WebSocketListener(this, settings), + last_state, + settings) {} + +WebSocketServerTransportAdapter::~WebSocketServerTransportAdapter() {} + +void WebSocketServerTransportAdapter::TransportConfigUpdated( + const TransportConfig& new_config) { + LOG4CXX_AUTO_TRACE(logger_); + + transport_config_ = new_config; + + // call the method of parent class to trigger OnTransportConfigUpdated() for + // the listeners + TransportAdapterImpl::TransportConfigUpdated(new_config); +} + +TransportConfig WebSocketServerTransportAdapter::GetTransportConfiguration() const { + LOG4CXX_AUTO_TRACE(logger_); + return transport_config_; +} + +DeviceType WebSocketServerTransportAdapter::GetDeviceType() const { + return WEBENGINE_WEBSOCKET; +} + +DeviceSptr WebSocketServerTransportAdapter::AddDevice(DeviceSptr device) { + LOG4CXX_AUTO_TRACE(logger_); + webengine_device_ = device; + return TransportAdapterImpl::AddDevice(webengine_device_); +} + +TransportAdapter::Error WebSocketServerTransportAdapter::Init() { + LOG4CXX_AUTO_TRACE(logger_); + if (webengine_device_) { + AddDevice(webengine_device_); + } + return TransportAdapterImpl::Init(); +} + +} // namespace transport_adapter +} // namespace transport_manager diff --git a/src/components/transport_manager/src/websocket_server/websocket_transport_adapter.cc b/src/components/transport_manager/src/websocket_server/websocket_transport_adapter.cc deleted file mode 100644 index 0f601ea921..0000000000 --- a/src/components/transport_manager/src/websocket_server/websocket_transport_adapter.cc +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2020, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "transport_manager/websocket_server/websocket_transport_adapter.h" - -#include -#include -#include -#include - -#include -#include - -#include "transport_manager/websocket_server/websocket_listener.h" -#include "utils/logger.h" -#include "utils/threads/thread_delegate.h" - -namespace transport_manager { -namespace transport_adapter { - -CREATE_LOGGERPTR_GLOBAL(logger_, "WebSocketTransportAdapter") - -WebSocketTransportAdapter::WebSocketTransportAdapter( - resumption::LastState& last_state, const TransportManagerSettings& settings) - : TransportAdapterImpl(nullptr, - nullptr, - new WebSocketListener(this, settings), - last_state, - settings) {} - -WebSocketTransportAdapter::~WebSocketTransportAdapter() {} - -void WebSocketTransportAdapter::TransportConfigUpdated( - const TransportConfig& new_config) { - LOG4CXX_AUTO_TRACE(logger_); - - transport_config_ = new_config; - - // call the method of parent class to trigger OnTransportConfigUpdated() for - // the listeners - TransportAdapterImpl::TransportConfigUpdated(new_config); -} - -TransportConfig WebSocketTransportAdapter::GetTransportConfiguration() const { - LOG4CXX_AUTO_TRACE(logger_); - return transport_config_; -} - -DeviceType WebSocketTransportAdapter::GetDeviceType() const { - return WEBENGINE_WEBSOCKET; -} - -DeviceSptr WebSocketTransportAdapter::AddDevice(DeviceSptr device) { - LOG4CXX_AUTO_TRACE(logger_); - webengine_device_ = device; - return TransportAdapterImpl::AddDevice(webengine_device_); -} - -TransportAdapter::Error WebSocketTransportAdapter::Init() { - LOG4CXX_AUTO_TRACE(logger_); - if (webengine_device_) { - AddDevice(webengine_device_); - } - return TransportAdapterImpl::Init(); -} - -} // namespace transport_adapter -} // namespace transport_manager -- cgit v1.2.1