Skip to content

Instantly share code, notes, and snippets.

@sandorkan
Created November 7, 2012 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandorkan/4030389 to your computer and use it in GitHub Desktop.
Save sandorkan/4030389 to your computer and use it in GitHub Desktop.
Creation of DataReader
// Create the data reader using the default publisher
StringDataReader dataReader = (StringDataReader) participant.create_datareader(
topic, //Topic
Subscriber.DATAREADER_QOS_DEFAULT, // QoS
new HelloSubscriber(), // Listener
StatusKind.DATA_AVAILABLE_STATUS); // mask
if (dataReader == null) {
System.err.println("Unable to create DDS Data Reader");
return;
}
// Reading User-Input
System.out.println("Ready to read data.");
System.out.println("Press CTRL+C to terminate.");
for (;;) {
try {
Thread.sleep(2000);
if(shutdown_flag) break;
} catch (InterruptedException e) {
// Nothing to do...
}
}
System.out.println("Shutting down...");
// Deleting entities and DomainParticipant
participant.delete_contained_entities();
DomainParticipantFactory.get_instance().delete_participant(participant);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment