@@ -44,9 +44,14 @@ SubscriberApp::SubscriberApp(
4444 , type_(new FlowControlPubSubType())
4545 , samples_(config.samples)
4646 , stop_(false )
47+ , slow_writer_guid({0 })
48+ , fast_writer_guid({0 })
4749{
50+ StatusMask status_mask = StatusMask::none ();
51+ status_mask << StatusMask::data_available ();
52+ status_mask << StatusMask::subscription_matched ();
4853 // Create Participant
49- participant_ = DomainParticipantFactory::get_instance ()->create_participant (0 , PARTICIPANT_QOS_DEFAULT );
54+ participant_ = DomainParticipantFactory::get_instance ()->create_participant (0 , PARTICIPANT_QOS_DEFAULT , this , status_mask );
5055 if (participant_ == nullptr )
5156 {
5257 throw std::runtime_error (" Participant initialization failed" );
@@ -125,15 +130,15 @@ void SubscriberApp::on_data_available(
125130 static unsigned int fastMessages = 0 ;
126131 static unsigned int slowMessages = 0 ;
127132
128- if (msg. wasFast () )
133+ if (info. sample_identity . writer_guid (). entityId == fast_writer_guid )
129134 {
130135 fastMessages++;
131- std::cout << " Sample RECEIVED from fast writer, count=" << fastMessages << std::endl;
136+ std::cout << " Sample RECEIVED from FAST writer, count=" << fastMessages << std::endl;
132137 }
133- else
138+ else if (info. sample_identity . writer_guid (). entityId == slow_writer_guid)
134139 {
135140 slowMessages++;
136- std::cout << " Sample RECEIVED from slow writer, count=" << slowMessages << std::endl;
141+ std::cout << " Sample RECEIVED from SLOW writer, count=" << slowMessages << std::endl;
137142 }
138143
139144 if ((samples_ > 0 ) && (fastMessages >= samples_) && (slowMessages >= samples_))
@@ -144,6 +149,26 @@ void SubscriberApp::on_data_available(
144149 }
145150}
146151
152+ void SubscriberApp::on_data_writer_discovery (
153+ DomainParticipant* /* participant*/ ,
154+ eprosima::fastdds::rtps::WriterDiscoveryInfo&& info,
155+ bool & /* should_be_ignored*/ )
156+ {
157+ std::vector<eprosima::fastdds::rtps::octet> slow_writer_id = {0 };
158+ std::vector<eprosima::fastdds::rtps::octet> fast_writer_id = {1 };
159+
160+ if (info.info .m_qos .m_userData .data_vec () == fast_writer_id)
161+ {
162+ fast_writer_guid = info.info .guid ().entityId ;
163+ std::cout << " Fast writer id " << fast_writer_guid << std::endl;
164+ }
165+ else if (info.info .m_qos .m_userData .data_vec () == slow_writer_id)
166+ {
167+ slow_writer_guid = info.info .guid ().entityId ;
168+ std::cout << " Slow writer id " << slow_writer_guid << std::endl;
169+ }
170+ }
171+
147172void SubscriberApp::run ()
148173{
149174 std::unique_lock<std::mutex> lck (terminate_cv_mtx_);
0 commit comments