TsgcWSPClient_MQTT | MQTT Publish Message

You can publish messages to all subscribers of a Topic using Publish method, which has the following parameters:

 

Topic: is the name of the topic where the message will be published.

Text: is the text of the message.

QoS: one of the 3 QoS levels (not all brokers support all 3 levels). If not specificed uses mtqsAtMostOnce. Read more about QoS Levels.

Retain: if true, this message will be retained. And every time a new client subscribes to this topic, this message will be sent to this client.

PublishProperties: if MQTT 5.0, these are the properties of the message.

 

Publish a simple message


MQTT.Publish('topic1', 'Hello Subscribers topic1');

 

Publish QoS = At Least Once


MQTT.Publish('topic1', 'Hello Subscribers topic1', mtqsAtLeastOnce);

 

Publish Retained message


MQTT.Publish('topic1', 'Hello Subscribers topic1', mtqsAtMostOnce, true);