From 38b9822860cfeb7c666c3ba88255e6da6febc4e3 Mon Sep 17 00:00:00 2001 From: nsubiron Date: Tue, 16 Oct 2018 12:48:36 +0200 Subject: [PATCH] Make sure we don't subscribe twice to same stream --- LibCarla/source/carla/streaming/Client.h | 2 ++ LibCarla/source/carla/streaming/low_level/Client.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/LibCarla/source/carla/streaming/Client.h b/LibCarla/source/carla/streaming/Client.h index 9b6d8324d..d29ffba3d 100644 --- a/LibCarla/source/carla/streaming/Client.h +++ b/LibCarla/source/carla/streaming/Client.h @@ -33,6 +33,8 @@ namespace streaming { _service.Stop(); } + /// @warning cannot subscribe twice to the same stream (even if it's a + /// MultiStream). template void Subscribe(const Token &token, Functor &&callback) { _client.Subscribe(_service.service(), token, std::forward(callback)); diff --git a/LibCarla/source/carla/streaming/low_level/Client.h b/LibCarla/source/carla/streaming/low_level/Client.h index 71a7ad94b..533a7e3e1 100644 --- a/LibCarla/source/carla/streaming/low_level/Client.h +++ b/LibCarla/source/carla/streaming/low_level/Client.h @@ -46,11 +46,14 @@ namespace low_level { } } + /// @warning cannot subscribe twice to the same stream (even if it's a + /// MultiStream). template void Subscribe( boost::asio::io_service &io_service, token_type token, Functor &&callback) { + DEBUG_ASSERT_EQ(_clients.find(token.get_stream_id()), _clients.end()); if (!token.has_address()) { token.set_address(_fallback_address); }