@@ -403,7 +403,7 @@ void LocalStorage::Impl::PropertiesUpdated(TopicData* topic,
403403 NotifyTopic (topic, eventFlags | NT_EVENT_PROPERTIES);
404404 // check local flag so we don't echo back received properties changes
405405 if (m_network && sendNetwork) {
406- m_network->SetProperties (topic->handle , topic-> name , update);
406+ m_network->SetProperties (topic->name , update);
407407 }
408408}
409409
@@ -427,10 +427,10 @@ void LocalStorage::Impl::RefreshPubSubActive(TopicData* topic,
427427void LocalStorage::Impl::NetworkAnnounce (TopicData* topic,
428428 std::string_view typeStr,
429429 const wpi::json& properties,
430- NT_Publisher pubHandle ) {
430+ std::optional< int > pubuid ) {
431431 DEBUG4 (" LS NetworkAnnounce({}, {}, {}, {})" , topic->name , typeStr,
432- properties.dump (), pubHandle );
433- if (pubHandle != 0 ) {
432+ properties.dump (), pubuid. value_or (- 1 ) );
433+ if (pubuid. has_value () ) {
434434 return ; // ack of our publish; ignore
435435 }
436436
@@ -503,7 +503,7 @@ void LocalStorage::Impl::RemoveNetworkPublisher(TopicData* topic) {
503503 // this may result in a duplicate publish warning on the server side,
504504 // but send one anyway in this case just to be sure
505505 if (nextPub->active && m_network) {
506- m_network->Publish (nextPub->handle , topic-> handle , topic->name ,
506+ m_network->Publish (Handle{ nextPub->handle }. GetIndex () , topic->name ,
507507 topic->typeStr , topic->properties , nextPub->config );
508508 }
509509 }
@@ -561,7 +561,7 @@ LocalStorage::PublisherData* LocalStorage::Impl::AddLocalPublisher(
561561 }
562562
563563 if (publisher->active && m_network) {
564- m_network->Publish (publisher->handle , topic-> handle , topic->name ,
564+ m_network->Publish (Handle{ publisher->handle }. GetIndex () , topic->name ,
565565 topic->typeStr , topic->properties , config);
566566 }
567567 return publisher;
@@ -580,7 +580,7 @@ LocalStorage::Impl::RemoveLocalPublisher(NT_Publisher pubHandle) {
580580 }
581581
582582 if (publisher->active && m_network) {
583- m_network->Unpublish (publisher->handle , topic-> handle );
583+ m_network->Unpublish (Handle{ publisher->handle }. GetIndex () );
584584 }
585585
586586 if (publisher->active && !topic->localPublishers .empty ()) {
@@ -593,7 +593,7 @@ LocalStorage::Impl::RemoveLocalPublisher(NT_Publisher pubHandle) {
593593 topic->typeStr = nextPub->config .typeStr ;
594594 RefreshPubSubActive (topic, false );
595595 if (nextPub->active && m_network) {
596- m_network->Publish (nextPub->handle , topic-> handle , topic->name ,
596+ m_network->Publish (Handle{ nextPub->handle }. GetIndex () , topic->name ,
597597 topic->typeStr , topic->properties ,
598598 nextPub->config );
599599 }
@@ -619,7 +619,8 @@ LocalStorage::SubscriberData* LocalStorage::Impl::AddLocalSubscriber(
619619 }
620620 if (m_network && !subscriber->config .hidden ) {
621621 DEBUG4 (" -> NetworkSubscribe({})" , topic->name );
622- m_network->Subscribe (subscriber->handle , {{topic->name }}, config);
622+ m_network->Subscribe (Handle{subscriber->handle }.GetIndex (), {{topic->name }},
623+ config);
623624 }
624625
625626 // queue current value
@@ -647,7 +648,7 @@ LocalStorage::Impl::RemoveLocalSubscriber(NT_Subscriber subHandle) {
647648 }
648649 }
649650 if (m_network && !subscriber->config .hidden ) {
650- m_network->Unsubscribe (subscriber->handle );
651+ m_network->Unsubscribe (Handle{ subscriber->handle }. GetIndex () );
651652 }
652653 }
653654 return subscriber;
@@ -684,8 +685,8 @@ LocalStorage::MultiSubscriberData* LocalStorage::Impl::AddMultiSubscriber(
684685 }
685686 if (m_network && !subscriber->options .hidden ) {
686687 DEBUG4 (" -> NetworkSubscribe" );
687- m_network->Subscribe (subscriber->handle , subscriber-> prefixes ,
688- subscriber->options );
688+ m_network->Subscribe (Handle{ subscriber->handle }. GetIndex () ,
689+ subscriber->prefixes , subscriber-> options );
689690 }
690691 return subscriber;
691692}
@@ -703,7 +704,7 @@ LocalStorage::Impl::RemoveMultiSubscriber(NT_MultiSubscriber subHandle) {
703704 }
704705 }
705706 if (m_network && !subscriber->options .hidden ) {
706- m_network->Unsubscribe (subscriber->handle );
707+ m_network->Unsubscribe (Handle{ subscriber->handle }. GetIndex () );
707708 }
708709 }
709710 return subscriber;
@@ -977,7 +978,7 @@ bool LocalStorage::Impl::PublishLocalValue(PublisherData* publisher,
977978 if (publisher->topic ->IsCached ()) {
978979 publisher->topic ->lastValueNetwork = value;
979980 }
980- m_network->SetValue (publisher->handle , value);
981+ m_network->SetValue (Handle{ publisher->handle }. GetIndex () , value);
981982 }
982983 return SetValue (publisher->topic , value, NT_EVENT_VALUE_LOCAL,
983984 suppressDuplicates, publisher);
@@ -1076,10 +1077,10 @@ LocalStorage::~LocalStorage() = default;
10761077NT_Topic LocalStorage::NetworkAnnounce (std::string_view name,
10771078 std::string_view typeStr,
10781079 const wpi::json& properties,
1079- NT_Publisher pubHandle ) {
1080+ std::optional< int > pubuid ) {
10801081 std::scoped_lock lock{m_mutex};
10811082 auto topic = m_impl.GetOrCreateTopic (name);
1082- m_impl.NetworkAnnounce (topic, typeStr, properties, pubHandle );
1083+ m_impl.NetworkAnnounce (topic, typeStr, properties, pubuid );
10831084 return topic->handle ;
10841085}
10851086
@@ -1124,25 +1125,26 @@ void LocalStorage::Impl::StartNetwork(net::NetworkInterface* network) {
11241125 PublisherData* anyPublisher = nullptr ;
11251126 for (auto && publisher : topic->localPublishers ) {
11261127 if (publisher->active ) {
1127- network->Publish (publisher->handle , topic-> handle , topic->name ,
1128+ network->Publish (Handle{ publisher->handle }. GetIndex () , topic->name ,
11281129 topic->typeStr , topic->properties , publisher->config );
11291130 anyPublisher = publisher;
11301131 }
11311132 }
11321133 if (anyPublisher && topic->lastValue ) {
1133- network->SetValue (anyPublisher->handle , topic->lastValue );
1134+ network->SetValue (Handle{anyPublisher->handle }.GetIndex (),
1135+ topic->lastValue );
11341136 }
11351137 }
11361138 for (auto && subscriber : m_subscribers) {
11371139 if (!subscriber->config .hidden ) {
1138- network->Subscribe (subscriber-> handle , {{ subscriber->topic -> name }} ,
1139- subscriber->config );
1140+ network->Subscribe (Handle{ subscriber->handle }. GetIndex () ,
1141+ {{subscriber-> topic -> name }}, subscriber->config );
11401142 }
11411143 }
11421144 for (auto && subscriber : m_multiSubscribers) {
11431145 if (!subscriber->options .hidden ) {
1144- network->Subscribe (subscriber->handle , subscriber-> prefixes ,
1145- subscriber->options );
1146+ network->Subscribe (Handle{ subscriber->handle }. GetIndex () ,
1147+ subscriber->prefixes , subscriber-> options );
11461148 }
11471149 }
11481150}
0 commit comments