Make sure we don't subscribe twice to same stream

This commit is contained in:
nsubiron 2018-10-16 12:48:36 +02:00
parent f159a0eacf
commit 38b9822860
2 changed files with 5 additions and 0 deletions

View File

@ -33,6 +33,8 @@ namespace streaming {
_service.Stop();
}
/// @warning cannot subscribe twice to the same stream (even if it's a
/// MultiStream).
template <typename Functor>
void Subscribe(const Token &token, Functor &&callback) {
_client.Subscribe(_service.service(), token, std::forward<Functor>(callback));

View File

@ -46,11 +46,14 @@ namespace low_level {
}
}
/// @warning cannot subscribe twice to the same stream (even if it's a
/// MultiStream).
template <typename Functor>
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);
}