Skip to content

Instantly share code, notes, and snippets.

@sandorkan
Created November 7, 2012 09:46
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/4030451 to your computer and use it in GitHub Desktop.
Save sandorkan/4030451 to your computer and use it in GitHub Desktop.
Implementation of callback-method on_data_available() of HelloSubscriber
public void on_data_available(DataReader reader) {
// Method Parameter of Type DataReader must be cast to Data Type of DataReader for this Topic
StringDataReader stringReader = (StringDataReader) reader;
SampleInfo info = new SampleInfo();
for (;;) {
try {
String sample = stringReader.take_next_sample(info);
if (info.valid_data) {
System.out.println(sample);
if (sample.equals("")) {
shutdown_flag = true;
}
}
}
catch (RETCODE_NO_DATA noData) {
// No more data to read
break;
}
catch (RETCODE_ERROR e) {
// An error occurred
e.printStackTrace();
}
}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment