AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Comunicación / Funciones MQTTT
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Publishes a message on the MQTT broker.
Ejemplo
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(gMqttSession, sTopic, bufContent)
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
Sintaxis
<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 the mqttSession variable corresponding to the MQTT session to be used.
<Topic>: Character string
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:
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.
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 uses 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.
<Procedure>: Optional procedure name
Name of the WLanguage procedure (also called "callback") executed when the message has been broadcast (this procedure is called if the constants mqttQualityExactlyOnce constants and mqttQualityAtLeastOnce constants constants are used). This procedure has the following format:
PROCEDURE <Procedure name>(<Session> is mqttSession,
<Message num> is int)
where:
  • <Session> corresponds to a mqttSession variable containing the characteristics of MQTT session.
  • <Message num> corresponds to the number of published message.
Clasificación Lógica de negocio / UI: Lógica de negocio
Componente: wd300com.dll
Versión mínima requerida
  • Versión 22
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 28/03/2025

Señalar un error o enviar una sugerencia | Ayuda local