Skip to content

Instantly share code, notes, and snippets.

@sandorkan
Created November 7, 2012 09:17
Show Gist options
  • Save sandorkan/4030332 to your computer and use it in GitHub Desktop.
Save sandorkan/4030332 to your computer and use it in GitHub Desktop.
Class Definition, creation of DomainParticipant and Topic of HelloSubscriber
public class HelloSubscriber extends DataReaderAdapter {
// For clean shutdown sequence
private static boolean shutdown_flag = false;
public static final void main(String[] args) {
// Create the DDS Domain participant on domain ID 0
DomainParticipant participant = DomainParticipantFactory.get_instance().create_participant(
0, // Domain ID = 0
DomainParticipantFactory.PARTICIPANT_QOS_DEFAULT, // QoS
null, // listener
StatusKind.STATUS_MASK_NONE); // mask
if (participant == null) {
System.err.println("Unable to create domain participant");
return;
}
// Create the topic "Hello World" for the String type
Topic topic = participant.create_topic(
"Hello, World", // Topic Name
StringTypeSupport.get_type_name(), // Topic Data Type
DomainParticipant.TOPIC_QOS_DEFAULT, // QoS
null, // listener
StatusKind.STATUS_MASK_NONE); // mask
if (topic == null) {
System.err.println("Unable to create topic.");
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment