CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
streaming
detail
tcp
streaming/detail/tcp/Client.h
Go to the documentation of this file.
1
// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#pragma once
8
9
#include "
carla/Buffer.h
"
10
#include "
carla/NonCopyable.h
"
11
#include "
carla/profiler/LifetimeProfiled.h
"
12
#include "
carla/streaming/detail/Token.h
"
13
#include "
carla/streaming/detail/Types.h
"
14
15
#include <boost/asio/io_context.hpp>
16
#include <boost/asio/ip/tcp.hpp>
17
#include <boost/asio/steady_timer.hpp>
18
#include <boost/asio/strand.hpp>
19
20
#include <atomic>
21
#include <functional>
22
#include <memory>
23
24
namespace
carla
{
25
26
class
BufferPool
;
27
28
namespace
streaming
{
29
namespace
detail
{
30
namespace
tcp
{
31
32
/// A client that connects to a single stream.
33
///
34
/// @warning This client should be stopped before releasing the shared pointer
35
/// or won't be destroyed.
36
class
Client
37
:
public
std::enable_shared_from_this<Client>,
38
private
profiler::LifetimeProfiled
,
39
private
NonCopyable
{
40
public
:
41
42
using
endpoint
= boost::asio::ip::tcp::endpoint;
43
using
protocol_type
= endpoint::protocol_type;
44
using
callback_function_type
= std::function<void (
Buffer
)>;
45
46
Client
(
47
boost::asio::io_context &io_context,
48
const
token_type
&token,
49
callback_function_type
callback);
50
51
~Client
();
52
53
void
Connect
();
54
55
stream_id_type
GetStreamId
()
const
{
56
return
_token
.
get_stream_id
();
57
}
58
59
void
Stop
();
60
61
private
:
62
63
void
Reconnect
();
64
65
void
ReadData
();
66
67
const
token_type
_token
;
68
69
callback_function_type
_callback
;
70
71
boost::asio::ip::tcp::socket
_socket
;
72
73
boost::asio::io_context::strand
_strand
;
74
75
boost::asio::steady_timer
_connection_timer
;
76
77
std::shared_ptr<BufferPool>
_buffer_pool
;
78
79
std::atomic_bool
_done
{
false
};
80
};
81
82
}
// namespace tcp
83
}
// namespace detail
84
}
// namespace streaming
85
}
// namespace carla
NonCopyable.h
LifetimeProfiled.h
Buffer.h
carla::BufferPool
A pool of Buffer.
Definition
BufferPool.h:29
carla::Buffer
A piece of raw data.
Definition
carla/Buffer.h:42
carla::NonCopyable::NonCopyable
NonCopyable()=default
carla::profiler::LifetimeProfiled
Definition
LifetimeProfiled.h:14
carla::streaming::Client::Client
Client()=default
carla::streaming::detail::tcp::Client::Stop
void Stop()
Definition
streaming/detail/tcp/Client.cpp:143
carla::streaming::detail::tcp::Client::Reconnect
void Reconnect()
Definition
streaming/detail/tcp/Client.cpp:160
carla::streaming::detail::tcp::Client::_strand
boost::asio::io_context::strand _strand
Definition
streaming/detail/tcp/Client.h:73
carla::streaming::detail::tcp::Client::~Client
~Client()
carla::streaming::detail::tcp::Client::_callback
callback_function_type _callback
Definition
streaming/detail/tcp/Client.h:69
carla::streaming::detail::tcp::Client::callback_function_type
std::function< void(Buffer)> callback_function_type
Definition
streaming/detail/tcp/Client.h:44
carla::streaming::detail::tcp::Client::_buffer_pool
std::shared_ptr< BufferPool > _buffer_pool
Definition
streaming/detail/tcp/Client.h:77
carla::streaming::detail::tcp::Client::Client
Client(boost::asio::io_context &io_context, const token_type &token, callback_function_type callback)
Definition
streaming/detail/tcp/Client.cpp:68
carla::streaming::detail::tcp::Client::_done
std::atomic_bool _done
Definition
streaming/detail/tcp/Client.h:79
carla::streaming::detail::tcp::Client::GetStreamId
stream_id_type GetStreamId() const
Definition
streaming/detail/tcp/Client.h:55
carla::streaming::detail::tcp::Client::endpoint
boost::asio::ip::tcp::endpoint endpoint
Definition
streaming/detail/tcp/Client.h:42
carla::streaming::detail::tcp::Client::ReadData
void ReadData()
Definition
streaming/detail/tcp/Client.cpp:170
carla::streaming::detail::tcp::Client::_socket
boost::asio::ip::tcp::socket _socket
Definition
streaming/detail/tcp/Client.h:71
carla::streaming::detail::tcp::Client::protocol_type
endpoint::protocol_type protocol_type
Definition
streaming/detail/tcp/Client.h:43
carla::streaming::detail::tcp::Client::_connection_timer
boost::asio::steady_timer _connection_timer
Definition
streaming/detail/tcp/Client.h:75
carla::streaming::detail::tcp::Client::_token
const token_type _token
Definition
streaming/detail/tcp/Client.h:67
carla::streaming::detail::tcp::Client::Connect
void Connect()
Definition
streaming/detail/tcp/Client.cpp:87
carla::streaming::detail::token_type
Serializes a stream endpoint.
Definition
detail/Token.h:61
carla::streaming::detail::token_type::get_stream_id
const auto & get_stream_id() const
Definition
detail/Token.h:116
Token.h
carla::streaming::detail::tcp
Definition
streaming/detail/tcp/Client.cpp:26
carla::streaming::detail
Definition
Dispatcher.cpp:17
carla::streaming::detail::stream_id_type
uint32_t stream_id_type
Definition
streaming/detail/Types.h:18
carla::streaming
Definition
client/detail/Client.h:61
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
Types.h
Generated by
1.18.0