Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] how to publish a .txt or pdf etc through MQTT

hi this is peiyuan, i got a reply from james that we are able to publish .txt or dpdf but i still do not get it.

Quotes (JAMES)
All you need to do is get a byte array of the data you want to send, publish it and then convert that byte array back into the correct format in your subscriber.

For example: if i am send a data.txt through mqtt (language i am using is java)

i need to buffer read all the data inside the data.txt and then store it in a variable for example a btye arrray? before sending it as payload 

Is there any tutorial or guide that i can follow to learn how to publish file or .txt through MQTT

lastly i had a question regarding to subscriber, why do subscriber need a QoS and also had to write the code for the Last will message?

for the last will  message basic on my understanding it is used when the user is disconnect due to network breakdown etc

hence can i write the source code for last will message 

if (!client.disconnect 
{    
    last will message 
}

if there is any tutorial i can had a look and learn from it 

thank you 
peiyuan



Back to the top