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

A client that connects to a single stream. More...

#include <Client.h>

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

Public Types

using callback_function_type = std::function< void(Buffer)>
 
using endpoint = boost::asio::ip::tcp::endpoint
 
using protocol_type = endpoint::protocol_type
 

Public Member Functions

 Client (boost::asio::io_context &io_context, const token_type &token, callback_function_type callback)
 
void Connect ()
 
stream_id_type GetStreamId () const
 
void Stop ()
 
 ~Client ()
 

Private Member Functions

void ReadData ()
 
void Reconnect ()
 
- 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
 
NonCopyableoperator= (const NonCopyable &)=delete
 
NonCopyableoperator= (NonCopyable &&)=delete
 

Private Attributes

std::shared_ptr< BufferPool_buffer_pool
 
callback_function_type _callback
 
boost::asio::deadline_timer _connection_timer
 
std::atomic_bool _done {false}
 
boost::asio::ip::tcp::socket _socket
 
boost::asio::io_context::strand _strand
 
const token_type _token
 

Detailed Description

A client that connects to a single stream.

Warning
This client should be stopped before releasing the shared pointer or won't be destroyed.

Definition at line 36 of file streaming/detail/tcp/Client.h.

Member Typedef Documentation

◆ callback_function_type

Definition at line 44 of file streaming/detail/tcp/Client.h.

◆ endpoint

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

Definition at line 42 of file streaming/detail/tcp/Client.h.

◆ protocol_type

Definition at line 43 of file streaming/detail/tcp/Client.h.

Constructor & Destructor Documentation

◆ Client()

carla::streaming::detail::tcp::Client::Client ( boost::asio::io_context &  io_context,
const token_type token,
callback_function_type  callback 
)

Definition at line 68 of file streaming/detail/tcp/Client.cpp.

References _token, carla::streaming::detail::token_type::protocol_is_tcp(), carla::throw_exception(), and ~Client().

+ Here is the call graph for this function:

◆ ~Client()

carla::streaming::detail::tcp::Client::~Client ( )
default

Referenced by Client().

+ Here is the caller graph for this function:

Member Function Documentation

◆ Connect()

void carla::streaming::detail::tcp::Client::Connect ( )

Definition at line 87 of file streaming/detail/tcp/Client.cpp.

References _done, _socket, _strand, _token, DEBUG_ASSERT, DEBUG_ASSERT_EQ, DEBUG_ONLY, carla::streaming::detail::token_type::get_stream_id(), carla::streaming::detail::token_type::is_valid(), carla::log_debug(), carla::log_info(), carla::streaming::detail::token_type::protocol_is_tcp(), ReadData(), Reconnect(), and carla::streaming::detail::token_type::to_tcp_endpoint().

Referenced by ReadData(), and Reconnect().

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

◆ GetStreamId()

stream_id_type carla::streaming::detail::tcp::Client::GetStreamId ( ) const
inline

Definition at line 55 of file streaming/detail/tcp/Client.h.

References _token, carla::streaming::detail::token_type::get_stream_id(), ReadData(), Reconnect(), and Stop().

+ Here is the call graph for this function:

◆ ReadData()

void carla::streaming::detail::tcp::Client::ReadData ( )
private

Definition at line 166 of file streaming/detail/tcp/Client.cpp.

References _buffer_pool, _done, _socket, _strand, Connect(), DEBUG_ASSERT_EQ, DEBUG_ASSERT_NE, DEBUG_ONLY, and carla::log_debug().

Referenced by Connect(), and GetStreamId().

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

◆ Reconnect()

void carla::streaming::detail::tcp::Client::Reconnect ( )
private

Definition at line 156 of file streaming/detail/tcp/Client.cpp.

References _connection_timer, Connect(), and carla::time_duration::seconds().

Referenced by Connect(), and GetStreamId().

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

◆ Stop()

void carla::streaming::detail::tcp::Client::Stop ( void  )

Definition at line 145 of file streaming/detail/tcp/Client.cpp.

References _connection_timer, _done, _socket, and _strand.

Referenced by GetStreamId().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _buffer_pool

std::shared_ptr<BufferPool> carla::streaming::detail::tcp::Client::_buffer_pool
private

Definition at line 77 of file streaming/detail/tcp/Client.h.

Referenced by ReadData().

◆ _callback

callback_function_type carla::streaming::detail::tcp::Client::_callback
private

Definition at line 69 of file streaming/detail/tcp/Client.h.

◆ _connection_timer

boost::asio::deadline_timer carla::streaming::detail::tcp::Client::_connection_timer
private

Definition at line 75 of file streaming/detail/tcp/Client.h.

Referenced by Reconnect(), and Stop().

◆ _done

std::atomic_bool carla::streaming::detail::tcp::Client::_done {false}
private

Definition at line 79 of file streaming/detail/tcp/Client.h.

Referenced by Connect(), ReadData(), and Stop().

◆ _socket

boost::asio::ip::tcp::socket carla::streaming::detail::tcp::Client::_socket
private

Definition at line 71 of file streaming/detail/tcp/Client.h.

Referenced by Connect(), ReadData(), and Stop().

◆ _strand

boost::asio::io_context::strand carla::streaming::detail::tcp::Client::_strand
private

Definition at line 73 of file streaming/detail/tcp/Client.h.

Referenced by Connect(), ReadData(), and Stop().

◆ _token

const token_type carla::streaming::detail::tcp::Client::_token
private

Definition at line 67 of file streaming/detail/tcp/Client.h.

Referenced by Client(), Connect(), and GetStreamId().


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