SMACC2
Loading...
Searching...
No Matches
cl_http::CpHttpSessionManager Class Reference

#include <cp_http_session_manager.hpp>

Inheritance diagram for cl_http::CpHttpSessionManager:
Inheritance graph
Collaboration diagram for cl_http::CpHttpSessionManager:
Collaboration graph

Classes

class  ServerConfig
 

Public Member Functions

 CpHttpSessionManager ()
 
virtual ~CpHttpSessionManager ()
 
void onInitialize () override
 
void setServerUrl (const std::string &server_url)
 
std::shared_ptr< http_session_basecreateSession (boost::asio::any_io_executor executor, std::function< void(const http_session_base::TResponse &)> callback)
 
bool isSSL () const
 
std::string getServerName () const
 
std::string getPort () const
 
- Public Member Functions inherited from smacc2::ISmaccComponent
 ISmaccComponent ()
 
virtual ~ISmaccComponent ()
 
virtual std::string getName () const
 

Private Attributes

std::unique_ptr< ServerConfigserver_config_
 
boost::asio::ssl::context ssl_context_
 
bool initialized_
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::ISmaccComponent
template<typename TOrthogonal , typename TClient >
void onComponentInitialization ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
template<typename TComponent >
void requiresComponent (TComponent *&requiredComponentStorage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
template<typename TComponent >
void requiresComponent (std::string name, TComponent *&requiredComponentStorage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
template<typename TClient >
void requiresClient (TClient *&requiredClientStorage)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createSiblingComponent (TArgs... targs)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createSiblingNamedComponent (std::string name, TArgs... targs)
 
rclcpp::Node::SharedPtr getNode ()
 
rclcpp::Logger getLogger () const
 
ISmaccStateMachinegetStateMachine ()
 
- Protected Attributes inherited from smacc2::ISmaccComponent
ISmaccStateMachinestateMachine_
 
ISmaccClientowner_
 

Detailed Description

Definition at line 33 of file cp_http_session_manager.hpp.

Constructor & Destructor Documentation

◆ CpHttpSessionManager()

cl_http::CpHttpSessionManager::CpHttpSessionManager ( )

Definition at line 43 of file cp_http_session_manager.cpp.

44: ssl_context_(boost::asio::ssl::context::tlsv13_client), initialized_(false)
45{
46 ssl_context_.set_default_verify_paths();
47 ssl_context_.set_verify_mode(boost::asio::ssl::verify_peer);
48}
boost::asio::ssl::context ssl_context_

References ssl_context_.

◆ ~CpHttpSessionManager()

cl_http::CpHttpSessionManager::~CpHttpSessionManager ( )
virtual

Definition at line 50 of file cp_http_session_manager.cpp.

50{}

Member Function Documentation

◆ createSession()

std::shared_ptr< http_session_base > cl_http::CpHttpSessionManager::createSession ( boost::asio::any_io_executor executor,
std::function< void(const http_session_base::TResponse &)> callback )

Definition at line 59 of file cp_http_session_manager.cpp.

62{
63 if (!server_config_)
64 {
65 throw std::runtime_error("Server URL not configured");
66 }
67
68 if (server_config_->isSSL())
69 {
70 return std::make_shared<ssl_http_session>(executor, ssl_context_, callback);
71 }
72 else
73 {
74 return std::make_shared<http_session>(executor, callback);
75 }
76}
std::unique_ptr< ServerConfig > server_config_

References server_config_, and ssl_context_.

Referenced by cl_http::CpHttpRequestExecutor::executeRequest().

Here is the caller graph for this function:

◆ getPort()

std::string cl_http::CpHttpSessionManager::getPort ( ) const

Definition at line 88 of file cp_http_session_manager.cpp.

89{
90 return server_config_ ? server_config_->getPort() : "";
91}

References server_config_.

Referenced by cl_http::CpHttpRequestExecutor::executeRequest().

Here is the caller graph for this function:

◆ getServerName()

std::string cl_http::CpHttpSessionManager::getServerName ( ) const

Definition at line 83 of file cp_http_session_manager.cpp.

84{
85 return server_config_ ? server_config_->getServerName() : "";
86}

References server_config_.

Referenced by cl_http::CpHttpRequestExecutor::executeRequest().

Here is the caller graph for this function:

◆ isSSL()

bool cl_http::CpHttpSessionManager::isSSL ( ) const

Definition at line 78 of file cp_http_session_manager.cpp.

79{
80 return server_config_ ? server_config_->isSSL() : false;
81}

References server_config_.

Referenced by cl_http::CpHttpRequestExecutor::executeRequest().

Here is the caller graph for this function:

◆ onInitialize()

void cl_http::CpHttpSessionManager::onInitialize ( )
overridevirtual

Reimplemented from smacc2::ISmaccComponent.

Definition at line 52 of file cp_http_session_manager.cpp.

52{ initialized_ = true; }

References initialized_.

◆ setServerUrl()

void cl_http::CpHttpSessionManager::setServerUrl ( const std::string & server_url)

Definition at line 54 of file cp_http_session_manager.cpp.

55{
56 server_config_ = std::make_unique<ServerConfig>(server_url);
57}

References server_config_.

Referenced by cl_http::ClHttp::onComponentInitialization().

Here is the caller graph for this function:

Member Data Documentation

◆ initialized_

bool cl_http::CpHttpSessionManager::initialized_
private

Definition at line 76 of file cp_http_session_manager.hpp.

Referenced by onInitialize().

◆ server_config_

std::unique_ptr<ServerConfig> cl_http::CpHttpSessionManager::server_config_
private

◆ ssl_context_

boost::asio::ssl::context cl_http::CpHttpSessionManager::ssl_context_
private

Definition at line 75 of file cp_http_session_manager.hpp.

Referenced by CpHttpSessionManager(), and createSession().


The documentation for this class was generated from the following files: