Working with data writers.
More...
Working with data writers.
Setting up a data writer
- Create a data writer, FooDataWriter, of user data type
Foo:
DataWriterQos writer_qos = new DataWriterQos();
MyWriterListener writer_listener = new MyWriterListener();
publisher.get_default_datawriter_qos(writer_qos);
FooDataWriter writer = null;
try {
writer = (FooDataWriter) publisher.create_datawriter(topic, writer_qos,
writer_listener,
StatusKind.STATUS_MASK_ALL);
} catch (RETCODE_ERROR err) {
}
Managing instances
Sending data
- Write instance of type
Foo
Foo data = new Foo();
InstanceHandle_t instance_handle
= InstanceHandle_t.HANDLE_NIL;
try {
writer.write(data, instance_handle);
} catch (RETCODE_ERR err) {
}
Tearing down a data writer
- Delete DataWriter:
try {
publisher.delete_datawriter(writer);
} catch (RETCODE_ERR err) {
}