CARLA
Loading...
Searching...
No Matches
carla::streaming::detail::tcp::Server Class Reference

#include <Server.h>

Inheritance 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.
 Server (boost::asio::io_context &io_context, endpoint ep)
void SetSynchronousMode (bool is_synchro)
void SetTimeout (time_duration timeout)
 Set session time-out.

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
NonCopyable & operator= (const NonCopyable &)=delete
NonCopyable & operator= (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 21 of file Server.cpp.

References _acceptor, _io_context, _synchronous, _timeout, and carla::SetSocketCloseOnExec().

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(), and TEST().

◆ IsSynchronousMode()

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

◆ 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(), and TEST().

◆ 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 33 of file Server.cpp.

References _acceptor, _io_context, and OpenSession().

Referenced by Listen(), and OpenSession().

◆ 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(), and TEST().

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(), OpenSession(), and Server().

◆ _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(), OpenSession(), and Server().

◆ _synchronous

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

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

Referenced by IsSynchronousMode(), Server(), 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(), Server(), and SetTimeout().


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