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();
DataWriterListener writer_listener = null;
try {
publisher.get_default_datawriter_qos(writer_qos);
} catch (DDS.Exception) {
Console.WriteLine(
"***Error: failed to get default datawriter qos");
}
DataWriter writer = publisher.create_datawriter(topic,
writer_qos,
writer_listener,
if (writer == null) {
Console.WriteLine("***Error: failed to create writer");
}
Managing instances
Sending data
- Write instance of type
Foo
InstanceHandle_t instance_handle =
InstanceHandle_t.HANDLE_NIL;
try {
writer.write(data, ref instance_handle);
} catch (DDS.Exception) {
Console.WriteLine("***Error: failed to write data");
}
Tearing down a data writer
- Delete DataWriter:
try {
publisher.delete_datawriter(ref writer);
} catch (DDS.Exception) {
Console.WriteLine("***Error: failed to delete writer");
}