Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to subscribe multiple topics ? #40

Open
iotproductions opened this issue Jun 8, 2018 · 4 comments
Open

How to subscribe multiple topics ? #40

iotproductions opened this issue Jun 8, 2018 · 4 comments

Comments

@iotproductions
Copy link

Hi,
I'm looking for a way to subscribe multiple topics, can you please give some examples about it ?
Thanks

@arcoirislabs
Copy link
Owner

arcoirislabs commented Jun 8, 2018 via email

@iotproductions
Copy link
Author

Hi @arcoirislabs ,
Yes I know it, but on listen function i can not found any params which return Topic name.
cordova.plugins.CordovaMqTTPlugin.listen("/topic/+singlewc/#multiwc",function(payload,params){ //Callback:- (If the user has published to /topic/room/hall) //payload : contains payload data //params : {singlewc:room,multiwc:hall} })

@arcoirislabs
Copy link
Owner

arcoirislabs commented Jun 8, 2018 via email

@iotproductions
Copy link
Author

iotproductions commented Jun 8, 2018

Hi @arcoirislabs ,
I follow your sources and here is my SUBSCRIBE function:

//Simple subscribe
cordova.plugins.CordovaMqTTPlugin.subscribe({
topic: "test_topic",
qos: 1,
success: function (s)
{
//New way to listen to topics
cordova.plugins.CordovaMqTTPlugin.listen("test_topic", function (payload, params) {
console.log("Received data: " + payload);
})
},
error: function (e) {
console.log("Something errors: " + e);
}
});

My function work fine but I'm looking for a way in order to Subscribe to any topic by user typed. It mean put dynamic topic into listen function. Could you please give me any suggestion to do it ? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants