Ian:
Thanks for your reply! Agreed that we should talk about this on paho mailing list in case others are also interested.
About the question: yes, I'm aware of the payload part, actually when I said "user-specific data", I was talking about the some context data used in the problem, not used by an end-user. To make this problem more complete, I will also shortly describe our use case here, in case we are using MQTT in a wrong way.
Instead of the normal pub/sub pattern, we are actually using MQTT in a slightly weirder way: in short, we implement a simple RCP on top of MQTT with the following setup:
1. We have a service (also treated as an MQTT client) that listens to certain topics of the broker(foo/+/bar for example).
2. We also have other clients that can send messages(requests) via foo/(client id)/bar channel, in the payload of the message, we include a randomly-generated message ID part.
3. When the service gets the message, it will perform certain actions, and send reply as a message through foo/(client id)/bar_response channel. The reply will also include the corresponding message ID.
4. The client gets the response from foo/(client id)/bar_response.
For this architecture to work, the client will need to subscribe to the response channel before sending the request. In addition, the client should also check if the message ID in the reply matches the message ID in the request part(to see if we have sent such a message). This means we have to maintain a list of currently-sent message IDs in the context data, which is exactly the context data I mentioned above, or "user-specific data" in my original email.
So this is the reason that I think we should add another (void*) as program-specific context data. And I think this should be included in the subscribe API function. In other words, we might want to change this API:
int MQTTSubscribe(Client* c, const char* topicFilter, enum QoS qos, messageHandler messageHandler);
to this one:
int MQTTSubscribe(Client* c, const char* topicFilter, enum QoS qos, messageHandler messageHandler, void* context);
Does this make sense to you? It might also be the case that we are using MQTT in the wrong way. Let me know what you think :)
Thanks a lot!