Hi, I am fairly new to DDS and I have been having a problem. I am currently evaluating DDS and I have been trying to see how to send a message just to one subscriber.
The example I am trying to make is to have two programs ( client and server ) and to send a command from the client which will be picked up from the server. The server will then send an acknowledgement back to the client. The cruicial thing is that there will be many clients who will not want to receive the response sent back to one client in particular. Is there a way to do this using DDS.
So far I have managed to use Builtin topics to discover other participants and I was planning on using the participant_key to identify the senders, however I can't seem to be able to get a particular key corresponding to the participant that sent a piece of data.
Is there a way, perhapes using DDS_SampleInfoSeq info_seq ; to get the key of the participant from which a piece of data has been sent?
You could model the client identification as part of the topic type. Lets say a client sends a sample of Topic A and the server acknowledges reception of such a sample by sending a sample of Topic B back to the client.
Consider adding a field to the topic type for both Topic A and B to identify a client. Each client has a DataWriter for Topic A and needs to make sure its identification is sent with each 'Topic A' request to the server. The server can simple re-use that identification in the 'Topic B' acknowledgement it sends back. By creating a ContentFilteredTopic that filters out other client identifications and a DataReader for that, a client will only receive the acknowledgements that are meant for him.
Furtermore, the SampleInfo that accompanies a sample that is read/taken contains a so-called 'publication_handle'. This is an instance handle that identifies the DataWriter that modified the instance.
I shall give what you suggested a try, although this sounds like it is being filtered out on the client side which means that the message is still being sent out to everyone. This would be ok in a small system but If I wanted to have hundreds of clients then I'd like to save on network traffic but just sending a message to the client that wants to receive it. Is there a way of doing this where the message is just sent directly between the client and server?
Most DDS implementations use multicast to distribute data over the network. This means data is sent over the network only once, independent of the number of subscribers.
DDS has especially been designed to be able to scale to thousands of publishers and subscribers in a robust manner. To prevent the scalability issues you mention, publishers and subscribers should not be aware of each others existence.
Applying content filters on the publisher side is possible, but then the publisher needs to 'know' all content filters applied by subscribers in the network and scalability becomes an issue again.