From 272f72e15fd0dcd63b78aeadd11e3e5e0e9d4e4c Mon Sep 17 00:00:00 2001 From: Eran Date: Mon, 15 Jan 2024 13:31:02 +0200 Subject: [PATCH] add notification-server::trigger-discovery-notifications() --- .../include/realdds/dds-notification-server.h | 2 ++ .../realdds/src/dds-notification-server.cpp | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/third-party/realdds/include/realdds/dds-notification-server.h b/third-party/realdds/include/realdds/dds-notification-server.h index fe22bbd59d0..aedc598cec5 100644 --- a/third-party/realdds/include/realdds/dds-notification-server.h +++ b/third-party/realdds/include/realdds/dds-notification-server.h @@ -41,6 +41,8 @@ class dds_notification_server // On-discovery notification: when a new client is detected void add_discovery_notification( topics::flexible_msg && notification ); + // Allow manual trigger of discovery + void trigger_discovery_notifications(); private: void send_discovery_notifications(); diff --git a/third-party/realdds/src/dds-notification-server.cpp b/third-party/realdds/src/dds-notification-server.cpp index baa4084e420..8e6ea4fbbb5 100644 --- a/third-party/realdds/src/dds-notification-server.cpp +++ b/third-party/realdds/src/dds-notification-server.cpp @@ -69,19 +69,14 @@ dds_notification_server::dds_notification_server( std::shared_ptr< dds_publisher _writer->on_publication_matched( [this]( PublicationMatchedStatus const & info ) { if( info.current_count_change == 1 ) { - { - std::lock_guard< std::mutex > lock( _notification_send_mutex ); - _send_init_msgs = true; - } - _send_notification_cv.notify_all(); + trigger_discovery_notifications(); } else if( info.current_count_change == -1 ) { } else { - LOG_ERROR( std::to_string( info.current_count_change ) - << " is not a valid value for on_publication_matched" ); + LOG_ERROR( info.current_count_change << " is not a valid value for on_publication_matched" ); } } ); @@ -126,6 +121,16 @@ dds_notification_server::~dds_notification_server() } +void dds_notification_server::trigger_discovery_notifications() +{ + { + std::lock_guard< std::mutex > lock( _notification_send_mutex ); + _send_init_msgs = true; + } + _send_notification_cv.notify_all(); +} + + void dds_notification_server::send_notification( topics::flexible_msg && notification ) { if( ! is_running() )