CARLA
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
carla::multigpu::Listener Class Reference

#include <listener.h>

+ Inheritance diagram for carla::multigpu::Listener:
+ Collaboration diagram for carla::multigpu::Listener:

Public Types

using callback_function_type = std::function< void(std::shared_ptr< Primary >)>
 
using callback_function_type_response = std::function< void(std::shared_ptr< Primary >, carla::Buffer)>
 
using endpoint = boost::asio::ip::tcp::endpoint
 
using protocol_type = endpoint::protocol_type
 
using Session = std::shared_ptr< Primary >
 

Public Member Functions

endpoint GetLocalEndpoint () const
 
void Listen (callback_function_type on_session_opened, callback_function_type on_session_closed, callback_function_type_response on_response)
 Start listening for connections. More...
 
 Listener (boost::asio::io_context &io_context, endpoint ep)
 
void SetTimeout (time_duration timeout)
 Set session time-out. More...
 
void Stop ()
 
 ~Listener ()
 

Private Member Functions

void OpenSession (time_duration timeout, callback_function_type on_session_opened, callback_function_type on_session_closed, callback_function_type_response on_response)
 
- 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
 
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 listener.h.

Member Typedef Documentation

◆ callback_function_type

using carla::multigpu::Listener::callback_function_type = std::function<void(std::shared_ptr<Primary>)>

Definition at line 32 of file listener.h.

◆ callback_function_type_response

Definition at line 33 of file listener.h.

◆ endpoint

using carla::multigpu::Listener::endpoint = boost::asio::ip::tcp::endpoint

Definition at line 29 of file listener.h.

◆ protocol_type

using carla::multigpu::Listener::protocol_type = endpoint::protocol_type

Definition at line 30 of file listener.h.

◆ Session

using carla::multigpu::Listener::Session = std::shared_ptr<Primary>

Definition at line 31 of file listener.h.

Constructor & Destructor Documentation

◆ Listener()

carla::multigpu::Listener::Listener ( boost::asio::io_context &  io_context,
endpoint  ep 
)
explicit

Definition at line 19 of file listener.cpp.

References _acceptor.

◆ ~Listener()

carla::multigpu::Listener::~Listener ( )

Definition at line 26 of file listener.cpp.

References Stop().

+ Here is the call graph for this function:

Member Function Documentation

◆ GetLocalEndpoint()

endpoint carla::multigpu::Listener::GetLocalEndpoint ( ) const
inline

Definition at line 38 of file listener.h.

References _acceptor.

◆ Listen()

void carla::multigpu::Listener::Listen ( callback_function_type  on_session_opened,
callback_function_type  on_session_closed,
callback_function_type_response  on_response 
)
inline

Start listening for connections.

On each new connection, on_session_opened is called, and on_session_closed when the session is closed, also on_response is called when an answer is received.

Definition at line 51 of file listener.h.

References _io_context, _timeout, OpenSession(), and Stop().

+ Here is the call graph for this function:

◆ OpenSession()

void carla::multigpu::Listener::OpenSession ( time_duration  timeout,
callback_function_type  on_session_opened,
callback_function_type  on_session_closed,
callback_function_type_response  on_response 
)
private

Definition at line 37 of file listener.cpp.

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

Referenced by Listen().

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

◆ SetTimeout()

void carla::multigpu::Listener::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 44 of file listener.h.

References _timeout.

◆ Stop()

void carla::multigpu::Listener::Stop ( void  )

Definition at line 30 of file listener.cpp.

References _acceptor, and _io_context.

Referenced by Listen(), and ~Listener().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _acceptor

boost::asio::ip::tcp::acceptor carla::multigpu::Listener::_acceptor
private

Definition at line 74 of file listener.h.

Referenced by GetLocalEndpoint(), Listener(), OpenSession(), and Stop().

◆ _io_context

boost::asio::io_context& carla::multigpu::Listener::_io_context
private

Definition at line 73 of file listener.h.

Referenced by Listen(), OpenSession(), and Stop().

◆ _timeout

std::atomic<time_duration> carla::multigpu::Listener::_timeout
private

Definition at line 75 of file listener.h.

Referenced by Listen(), and SetTimeout().


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