TsgcWSPClient_MQTT | Publish and Wait Response

MQTT client allows the use of some type of QoS levels, any of those levels works in a different level to be sure that messages have been processed as expected.

 

There are the following QoS levels:

 

 

You can handle the events OnPubAck or OnPubComp to know if message has been processed by server or you can use the method PublishAndWait to know if the message has been processed by the server.

The use of PublishAndWait is the same that normal Publish method, now you have a new parameter called Timeout, where method will return with value false if after certain period of time, there is no response from server. By default this value is 10 seconds.

 


if mqtt.PublishAndWait('topic', 'text') then
  ShowMessage('Message processed')
else
  ShowMessage('Message error');