|Re: [paho-dev] C++ get_client_id()|
The Client ID of the publisher is not carried along with the message
to the subscriber. Typically in a loosely-coupled architecture, you
don't worry about who sent the message, but rather what the message
is referring to. With MQTT this is done by creating a hierarchy of
message topics, and specific publishers can send messages to
For example, if you place temperature sensors around the house, you can create topics like:
data/temperature/kitchenThe sensor in the kitchen would publish to the topic "data/temperature/kitchen" and all subscribers could infer that messages on that topic came from the kitchen sensor. Of course, the benefit of this is that different subscribers could choose which messages they want to receive by subscribing to individual rooms, or they could ask to get all the temperature readings by subscribing to a wildcard, like "data/temperature/#". Of course, the topic is sent to the subscriber along with each message, even when subscribed with a wildcard.
But if you really want the Client ID of the sender, you could always add it to the playload of all your messages. But that might not be the greatest idea because it will tie the specific senders and receivers together a bit too tightly.
On 07/05/2017 12:11 AM, Haider Ali wrote: