@@ -223,26 +223,30 @@ void GatewayApplication::RegisterEventReceiveHandlerCallback(impl::GenericSkelet
223223 const std::string& specifier_str,
224224 const std::string& event_name)
225225{
226- // TODO: GenericSkeletonEvent::SetReceiveHandlerNotificationCallback is not yet available in the OSS impl.
227- // Once available, remove the (void) suppressions below and uncomment the implementation block.
228- (void )skeleton;
229- (void )specifier_str;
230- (void )event_name;
231-
232- // using NotificationCallback = safecpp::MoveOnlyScopedFunction<void(bool)>;
233- // auto scoped_callback = std::make_shared<NotificationCallback>(
234- // scope_, [this, specifier = specifier_str, event = event_name](bool has_subscribers) {
235- // OnSubscriptionStateChanged(specifier, event, has_subscribers);
236- // });
237- //
238- // auto result = skeleton.SetReceiveHandlerNotificationCallback(
239- // event_name, [scoped_callback](bool has_subscribers) { (*scoped_callback)(has_subscribers); });
240- //
241- // if (!result.has_value())
242- // {
243- // score::mw::log::LogError() << "GatewayApplication: Failed to set subscription callback for "
244- // << event_name << " of " << specifier_str;
245- // }
226+ using NotificationCallback = safecpp::MoveOnlyScopedFunction<void (bool )>;
227+ auto scoped_callback = std::make_shared<NotificationCallback>(
228+ scope_, [this , specifier = specifier_str, event = event_name](bool has_subscribers) {
229+ OnSubscriptionStateChanged (specifier, event, has_subscribers);
230+ });
231+
232+ auto event_map = skeleton.GetEvents ();
233+ auto event_it = event_map.find (event_name);
234+ if (event_it == event_map.cend ())
235+ {
236+ score::mw::log::LogError () << " GatewayApplication: Event " << event_name << " not found in skeleton for "
237+ << specifier_str;
238+ return ;
239+ }
240+
241+ auto result = event_it->second .SetReceiveHandlerRegistrationChangedHandler ([scoped_callback](bool has_subscribers) {
242+ (*scoped_callback)(has_subscribers);
243+ });
244+
245+ if (!result.has_value ())
246+ {
247+ score::mw::log::LogError () << " GatewayApplication: Failed to set subscription callback for " << event_name
248+ << " of " << specifier_str;
249+ }
246250}
247251
248252void GatewayApplication::OnSubscriptionStateChanged (const std::string& specifier_str,
0 commit comments