A TCP server session. More...
#include <primary.h>
Public Types | |
using | socket_type = boost::asio::ip::tcp::socket |
Public Member Functions | |
void | Close () |
Post a job to close the session. More... | |
void | Open (Listener::callback_function_type on_opened, Listener::callback_function_type on_closed, Listener::callback_function_type_response on_response) |
Starts the session and calls on_opened after successfully reading the stream id, and on_closed once the session is closed. More... | |
Primary (boost::asio::io_context &io_context, time_duration timeout, Listener &server) | |
void | ReadData () |
read data More... | |
void | Write (std::shared_ptr< const carla::streaming::detail::tcp::Message > message) |
Writes some data to the socket. More... | |
void | Write (std::string text) |
Writes a string. More... | |
template<typename... Buffers> | |
void | Write (Buffers... buffers) |
Writes some data to the socket. More... | |
~Primary () | |
Static Public Member Functions | |
template<typename... Buffers> | |
static auto | MakeMessage (Buffers... buffers) |
Private Member Functions | |
void | CloseNow (boost::system::error_code ec=boost::system::error_code()) |
void | StartTimer () |
Private Member Functions inherited from carla::profiler::LifetimeProfiled | |
LifetimeProfiled ()=default | |
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 | |
std::shared_ptr< BufferPool > | _buffer_pool |
boost::asio::deadline_timer | _deadline |
bool | _is_writing = false |
Listener::callback_function_type | _on_closed |
Listener::callback_function_type_response | _on_response |
Listener & | _server |
const size_t | _session_id |
socket_type | _socket |
boost::asio::io_context::strand | _strand |
time_duration | _timeout |
Friends | |
class | Listener |
A TCP server session.
When a session opens, it reads from the socket a stream id object and passes itself to the callback functor. The session closes itself after timeout of inactivity is met.
using carla::multigpu::Primary::socket_type = boost::asio::ip::tcp::socket |
|
explicit |
Definition at line 27 of file primary.cpp.
carla::multigpu::Primary::~Primary | ( | ) |
Definition at line 41 of file primary.cpp.
References _socket.
void carla::multigpu::Primary::Close | ( | ) |
Post a job to close the session.
Definition at line 176 of file primary.cpp.
References _strand.
Referenced by StartTimer(), and Write().
|
private |
Definition at line 203 of file primary.cpp.
References _deadline, _on_closed, _session_id, _socket, and carla::log_debug().
Referenced by Write().
|
inlinestatic |
Definition at line 54 of file primary.h.
References ReadData(), and Write().
Referenced by carla::multigpu::Router::Write(), Write(), carla::multigpu::Router::WriteToNext(), and carla::multigpu::Router::WriteToOne().
void carla::multigpu::Primary::Open | ( | Listener::callback_function_type | on_opened, |
Listener::callback_function_type | on_closed, | ||
Listener::callback_function_type_response | on_response | ||
) |
Starts the session and calls on_opened after successfully reading the stream id, and on_closed once the session is closed.
Definition at line 49 of file primary.cpp.
References _on_closed, _on_response, _socket, DEBUG_ASSERT, and ReadData().
void carla::multigpu::Primary::ReadData | ( | ) |
read data
Definition at line 122 of file primary.cpp.
References _strand, DEBUG_ASSERT_EQ, DEBUG_ASSERT_NE, DEBUG_ONLY, and carla::log_error().
Referenced by MakeMessage(), and Open().
|
private |
Definition at line 185 of file primary.cpp.
References _deadline, _session_id, Close(), carla::log_debug(), and carla::log_error().
Referenced by Write().
void carla::multigpu::Primary::Write | ( | std::shared_ptr< const carla::streaming::detail::tcp::Message > | message | ) |
Writes some data to the socket.
Definition at line 68 of file primary.cpp.
References _strand, DEBUG_ASSERT, DEBUG_ONLY, and carla::log_error().
Referenced by MakeMessage(), and Write().
void carla::multigpu::Primary::Write | ( | std::string | text | ) |
|
inline |
Writes some data to the socket.
Definition at line 72 of file primary.h.
References Close(), CloseNow(), MakeMessage(), StartTimer(), and Write().
|
private |
|
private |
Definition at line 95 of file primary.h.
Referenced by CloseNow(), and StartTimer().
|
private |
|
private |
Definition at line 99 of file primary.h.
Referenced by CloseNow(), and Open().
|
private |
|
private |
Definition at line 89 of file primary.h.
Referenced by CloseNow(), and StartTimer().
|
private |
Definition at line 91 of file primary.h.
Referenced by CloseNow(), Open(), and ~Primary().
|
private |
Definition at line 97 of file primary.h.
Referenced by Close(), ReadData(), and Write().
|
private |