CARLA
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
carla::streaming::detail::tcp::Server Class Reference

#include <Server.h>

+ Inheritance diagram for carla::streaming::detail::tcp::Server:
+ Collaboration diagram for carla::streaming::detail::tcp::Server:

Public Types

using endpoint = boost::asio::ip::tcp::endpoint
 
using protocol_type = endpoint::protocol_type
 

Public Member Functions

endpoint GetLocalEndpoint () const
 
bool IsSynchronousMode () const
 
template<typename FunctorT1 , typename FunctorT2 >
void Listen (FunctorT1 on_session_opened, FunctorT2 on_session_closed)
 Start listening for connections. More...
 
 Server (boost::asio::io_context &io_context, endpoint ep)
 
void SetSynchronousMode (bool is_synchro)
 
void SetTimeout (time_duration timeout)
 Set session time-out. More...
 

Private Member Functions

void OpenSession (time_duration timeout, ServerSession::callback_function_type on_session_opened, ServerSession::callback_function_type on_session_closed)
 
- Private Member Functions inherited from carla::NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
 NonCopyable (NonCopyable &&)=delete
 
NonCopyableoperator= (const NonCopyable &)=delete
 
NonCopyableoperator= (NonCopyable &&)=delete
 

Private Attributes

boost::asio::ip::tcp::acceptor _acceptor
 
boost::asio::io_context & _io_context
 
bool _synchronous
 
std::atomic< time_duration_timeout
 

Detailed Description

Warning
This server cannot be destructed before its io_context is stopped.

Definition at line 26 of file streaming/detail/tcp/Server.h.

Member Typedef Documentation

◆ endpoint

using carla::streaming::detail::tcp::Server::endpoint = boost::asio::ip::tcp::endpoint

Definition at line 29 of file streaming/detail/tcp/Server.h.

◆ protocol_type

Definition at line 30 of file streaming/detail/tcp/Server.h.

Constructor & Destructor Documentation

◆ Server()

carla::streaming::detail::tcp::Server::Server ( boost::asio::io_context &  io_context,
endpoint  ep 
)
explicit

Definition at line 20 of file Server.cpp.

Member Function Documentation

◆ GetLocalEndpoint()

endpoint carla::streaming::detail::tcp::Server::GetLocalEndpoint ( ) const
inline

Definition at line 34 of file streaming/detail/tcp/Server.h.

References _acceptor.

Referenced by TEST().

+ Here is the caller graph for this function:

◆ IsSynchronousMode()

bool carla::streaming::detail::tcp::Server::IsSynchronousMode ( ) const
inline

Definition at line 61 of file streaming/detail/tcp/Server.h.

References _synchronous, and OpenSession().

Referenced by carla::streaming::detail::tcp::ServerSession::Write().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Listen()

template<typename FunctorT1 , typename FunctorT2 >
void carla::streaming::detail::tcp::Server::Listen ( FunctorT1  on_session_opened,
FunctorT2  on_session_closed 
)
inline

Start listening for connections.

On each new connection, on_session_opened is called, and on_session_closed when the session is closed.

Definition at line 48 of file streaming/detail/tcp/Server.h.

References _io_context, _timeout, and OpenSession().

Referenced by TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OpenSession()

void carla::streaming::detail::tcp::Server::OpenSession ( time_duration  timeout,
ServerSession::callback_function_type  on_session_opened,
ServerSession::callback_function_type  on_session_closed 
)
private

Definition at line 26 of file Server.cpp.

References _acceptor, _io_context, and carla::log_error().

Referenced by IsSynchronousMode(), and Listen().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetSynchronousMode()

void carla::streaming::detail::tcp::Server::SetSynchronousMode ( bool  is_synchro)
inline

Definition at line 57 of file streaming/detail/tcp/Server.h.

References _synchronous.

◆ SetTimeout()

void carla::streaming::detail::tcp::Server::SetTimeout ( time_duration  timeout)
inline

Set session time-out.

Applies only to newly created sessions. By default the time-out is set to 10 seconds.

Definition at line 40 of file streaming/detail/tcp/Server.h.

References _timeout.

Referenced by TEST().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _acceptor

boost::asio::ip::tcp::acceptor carla::streaming::detail::tcp::Server::_acceptor
private

Definition at line 74 of file streaming/detail/tcp/Server.h.

Referenced by GetLocalEndpoint(), and OpenSession().

◆ _io_context

boost::asio::io_context& carla::streaming::detail::tcp::Server::_io_context
private

Definition at line 72 of file streaming/detail/tcp/Server.h.

Referenced by Listen(), and OpenSession().

◆ _synchronous

bool carla::streaming::detail::tcp::Server::_synchronous
private

Definition at line 78 of file streaming/detail/tcp/Server.h.

Referenced by IsSynchronousMode(), and SetSynchronousMode().

◆ _timeout

std::atomic<time_duration> carla::streaming::detail::tcp::Server::_timeout
private

Definition at line 76 of file streaming/detail/tcp/Server.h.

Referenced by Listen(), and SetTimeout().


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