PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Publishes a message on the MQTT broker.
Example
gMqttSession is mqttSession
llResult is int
sTopic is string
bufContent is Buffer

gMqttSession..Address = "xxx.xx.xxx.xxx" // To fill
gMqttSession..Port = 1883
gMqttSession..ClientID = "MyTest"
gMqttSession..CleanSession = True

sTopic = "/SERVER"
bufContenu = "test from windev"

IF NOT MQTTConnect(gMqttSession) THEN
Error("Connection problem. '" + ErrorInfo() + "')")
END

llResult = MQTTPublish(MQCnt, sTopic, bufContent)
<code WL>
llResult is int
sTopic = "/SERVER"
bufContenu = "test from windev"
llResult = MQTTPublish(gMqttSession, sTopic, bufContent, True, ...
mqttQualityExactlyOnce, PublicationMQTT)

INTERNAL PROCEDURE PublicationMQTT(pMqttSession is mqttSession, MessageNum is int)
Trace("Publication" + " - MessageNum = " + MessageNum)
END
Syntax
<Result> = MQTTPublish(<MQTT Session> , <Topic> , <Data> [, <To Store> [, <Quality of Service> [, <Procedure>]]])
<Result>: Integer
  • Number of published message (mqttQualityExactlyOnce and mqttQualityAtLeastOnce constants).
  • 0 if the publication is successful (mqttQualityAtMostOnce constant).
  • -1 if an error occurred.
<MQTT Session>: mqttSession variable
Name of mqttSession variable corresponding to the MQTT session to use.
<Topic>: Character string (with quotes)
Message topic.
<Data>: Buffer
Data to publish (must not exceed 256MB).
<To Store>: Optional boolean
  • True if the message must be stored on the server.
  • False (by default) otherwise.
<Quality of Service>: Optional integer
Requested service quality:
mqttQualityAtMostOnceThe message will be delivered once at most. The message is not stored. It is sent without guarantee of receipt. The MQTT (broker) does not inform the sender that the message was received. The message can be lost if the client is disconnected or if the server is stopped.
Equivalent to QOS set to 0.
mqttQualityExactlyOnceThe message will be necessarily saved by the issuer. It will be transmitted as long as the receiver does not confirm its sending on the network. The issuer is using a sophisticated recognition with the server (broker) to avoid duplicating messages. This mode is slower but it is more secure.
Equivalent to QOS set to 2.
mqttQualityAtLeastOnceThe message will be delivered at least once. The client will transmit the message several times if necessary until the server (broker) confirms that the message was transmitted on the network.
Equivalent to QOS set to 1.
<Procedure>: Optional character string
Name of WLanguage procedure ("callback") run when the message was published (this procedure is called if the mqttQualityExactlyOnce and mqttQualityAtLeastOnce constants are used). This procedure has the following format:
PROCEDURE <ProcedureName>(<Session> is mqttSession, <MessageNum> is int)
where:
  • <Session> corresponds to a mqttSession variable containing the characteristics of MQTT session.
  • <MessageNum> corresponds to the number of published message.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230com.dll
Minimum required version
  • Version 22
This page is also available for…
Comments
Click [Add] to post a comment