edusperoni/nativescript-mqtt

Implementation of publishing messages to broker

Closed this issue · 9 comments

How to publish message from app to the mqtt broker?

mqttClient.publish(message)

mqttClient.publish(new Message(new Message({
    destinationName: "topic",
    payloadString: "data to send"
}));

i'll definitely try this out.. If got all this working, is it okay that I will update readme to help others? :)

Sure, you're welcome to submit a PR :)

in the above code, I think new Message was duplicated causing the mqtt connection to close. But I got it working with this,

this.mqtt_client.publish(new Message({
destinationName: "PubMonitor",
payloadString: "data to send"
}));

I have question sir, what is the purpose of the other parameters?.. I can send to broker but I also get the message I sent which can be of course get rid of using conditionals..

image

The first line was just showing what method to call, the code you used is correct :)

very much explained.. thank you <3

Thanks @edusperoni for this amazing plugin. I struggled for days. I guess a documentation update will solve this issue for others.