Working with subscribers.
More...
Working with subscribers.
Setting up a subscriber
- 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
- Set up to handle the DDS_DATA_ON_READERS_STATUS status, in one or both of the following two ways.
Access received data via a subscriber
- 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);
}
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:
- Indicate that data will be accessed via the subscriber:
printf("***Error: failed to begin access\n");
}
- Indicate that the data access via the subscriber is done:
printf("***Error: failed to end access\n");
}
Tearing down a subscriber
- Delete DDS_Subscriber:
printf("***Error: failed to delete subscriber\n");
}