24#ifndef LIBCARLA_NO_EXCEPTIONS
27 auto stream_state = pair.second;
28 stream_state->ClearSessions();
29#ifndef LIBCARLA_NO_EXCEPTIONS
30 }
catch (
const std::exception &e) {
31 log_error(
"failed to clear sessions:", e.what());
38 std::lock_guard<std::mutex> lock(
_mutex);
41 std::shared_ptr<MultiStreamState> ptr;
61 std::lock_guard<std::mutex> lock(
_mutex);
62 log_debug(
"Calling CloseStream for ",
id);
65 auto stream_state = search->second;
67 log_debug(
"Disconnecting all sessions (stream ",
id,
")");
68 stream_state->ClearSessions();
76 std::lock_guard<std::mutex> lock(
_mutex);
77 auto search =
_stream_map.find(session->get_stream_id());
79 auto stream_state = search->second;
81 log_debug(
"Connecting session (stream ", session->get_stream_id(),
")");
82 stream_state->ConnectSession(std::move(session));
87 log_error(
"Invalid session: no stream available with id", session->get_stream_id());
93 std::lock_guard<std::mutex> lock(
_mutex);
94 log_debug(
"Calling DeregisterSession for ", session->get_stream_id());
95 auto search =
_stream_map.find(session->get_stream_id());
97 auto stream_state = search->second;
99 log_debug(
"Disconnecting session (stream ", session->get_stream_id(),
")");
100 stream_state->DisconnectSession(session);
107 std::lock_guard<std::mutex> lock(
_mutex);
108 log_debug(
"Searching sensor id: ", sensor_id);
111 log_debug(
"Found sensor id: ", sensor_id);
112 auto stream_state = search->second;
113 stream_state->ForceActive();
114 log_debug(
"Getting token from stream ", sensor_id,
" on port ", stream_state->token().get_port());
115 return stream_state->token();
117 log_debug(
"Not Found sensor id, creating sensor stream: ", sensor_id);
120 auto ptr = std::make_shared<MultiStreamState>(temp_token);
123 if (!result.second) {
124 log_debug(
"Failed to create multistream for stream ", sensor_id,
" on port ", temp_token.
get_port());
126 log_debug(
"Created token from stream ", sensor_id,
" on port ", temp_token.
get_port());
#define DEBUG_ASSERT(predicate)
void DeregisterSession(std::shared_ptr< Session > session)
carla::streaming::Stream MakeStream()
bool RegisterSession(std::shared_ptr< Session > session)
void CloseStream(carla::streaming::detail::stream_id_type id)
token_type GetToken(stream_id_type sensor_id)
Serializes a stream endpoint.
const auto & get_stream_id() const
void set_stream_id(stream_id_type id)
detail::Stream< detail::MultiStreamState > Stream
A stream represents an unidirectional channel for sending data from server to client.
This file contains definitions of common data structures used in traffic manager.
void throw_exception(const std::exception &e)
static void log_error(Args &&... args)
static void log_debug(Args &&... args)