Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] subscribing to multiple topics

Hello Ian,

 

Thank you for the quick feedback.

 

What I am actually trying to do (and I probably failed to explain it clearly) is to be able to subscribe to different topics (let’s say to up to 4 different topics).

Each subscription should have a different call-back function associated.

Each one of the 4 different call-back functions shall switch the state of its associated output (one output specifically associated to a given call-back function).

 

Therefore, if a message associated to one of the 4 topic I can subscribed to comes in, the associated output would be switch through the execution of its respective call-back (the one registered to the target topic during the subscription process).

 

So only one call-back function shall be invoked for an incoming message but the invoked function would depend on the topic of the message.

 

Let’s say that

-        The callback function switchOutput1 is associated with the topic “house/temperature”

-        The callback function switchOutput2 is associated with the topic “garden/humidity”

 

I want that, when a message is published on the topic “house/temperature”, at its reception in my device, I execute the function switchOutput1.

Respectively, when a message is published on the topic “garden/humidity”, at its reception in my device, I execute the function switchOutput2.

 

For the moment, my topics (which correspond to messages I publish when one of my input changes its state) are formatted such as “MyMod1/INx/InputEvent”, though I would like to be able to associate a topic which might not be related to the one I generate from my device.

 

I hope it clarifies my purpose.

 

François Macé

 


Back to the top