Publications

An application uses DataWriters to send data. A DataWriter is associated with a single Topic. You can have multiple DataWriters and Topics in a single application. In addition, you can have more than one DataWriter for a particular Topic in a single application. Publishers own and manage DataWriters.

To create a DataWriter, you need a Topic (see Topics) and a DomainParticipant. Additionally, you may add a QoS parameter and a listener.

The following code creates a DataWriter for the Topic we created in the Topics section:

publisher = dds.Publisher(participant)
writer = dds.DataWriter(publisher, topic)

To publish data, create a sample, set the values, and write it:

data = Point(x=1, y=2)
writer.write(data)

A special DataWriter type for DynamicData, DynamicData.DataWriter is also available. Find more information in DynamicType and DynamicData.