Working with subscribers.
More...
Working with subscribers.
Setting up a subscriber
- Set up participant
- Create a DDS_Subscriber
MySubscriberListener_DataOnReaders;
MySubscriberListener_RequestedDeadlineMissed;
MySubscriberListener_RequestedIncompatibleQos;
MySubscriberListener_SampleRejected;
MySubscriberListener_LivelinessChanged;
MySubscriberListener_DataAvailable;
MySubscriberListener_SubscriptionMatch;
MySubscriberListener_SampleLost;
&subscriber_qos);
printf("***Error: failed to get default subscriber qos\n");
}
&subscriber_qos,
&subscriber_listener ,
if (subscriber == NULL) {
printf("***Error: failed to create subscriber\n");
}
Set up subscriber to access received data
Access received data via a subscriber
- Ensure subscriber is set up to access received data
- Get the list of readers that have data samples available:
&reader_seq,
max_samples,
sample_state_mask,
view_state_mask,
instance_state_mask);
printf("***Error: failed to access received data via subscriber\n");
return;
}
- Upon successfully getting the list of readers with data, process the data readers to either:
If the intent is to access the data coherently or in order, the list of data readers must be processed in the order returned:
int i;
for(i = 0; i < DDS_DataReaderSeq_get_length(&reader_seq); ++i) {
TDataReader* reader = DDS_DataReaderSeq_get_reference(&reader_seq, i);
}
- Alternatively, call DDS_Subscriber_notify_datareaders to invoke the DDS_DataReaderListener for each of the data readers.
printf("***Error: failed to notify datareaders\n");
}
Access received data coherently and/or in order
To access the received data coherently and/or in an ordered manner, according to the settings of the DDS_PresentationQosPolicy attached to a DDS_Subscriber:
Tearing down a subscriber
- Delete DDS_Subscriber:
printf("***Error: failed to delete subscriber\n");
}