PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Properties specific to the description of mqttSession variables
  • Authentication mode
  • Functions that handle the mqttSession variables
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
mqttSession (Type of variable)
In French: mqttSession
The mqttSession type is used to define the parameters for connecting to the MQTT broker. These connection parameters can be defined and modified by several WLanguage properties.
Note: See Declaring a variable for more details.
Example
// Declare the MQTT connection
gMqttSession is mqttSession

// Retrieves the data typed in the connection window
gMqttSession..Address = EDT_Broker_Address
gMqttSession..Port = EDT_Port
gMqttSession..Option = CBOX_SSL
gMqttSession..ConnectionTimeOut = EDT_Connection_TimeOut
gMqttSession..User = EDT_Login
gMqttSession..UserPassword = EDT_PSW
gMqttSession..PrivateKey = EDT_Private_Key
gMqttSession..PrivateKeyPassword = EDT_Private_Key_PSW
gMqttSession..ClientID = EDT_ClientID
gMqttSession..CleanSession = CBOX_Clean_Session
IF MQTTConnect(gMqttSession) THEN
Message("Connection OK")
ELSE
Error("Connection problem. '" + ErrorInfo() + "')")
END
Remarks

Properties specific to the description of mqttSession variables

The following properties can be used to handle a MQTT session:
Property nameType usedEffect
AddressCharacter stringAddress of MQTT server (also called "MQTT broker"). This address can be given in the following format:
  • IP address in XXX.XXX.XXX.XXX format (125.5.110.100 for example).
  • IP address containing the server name (MQTTServer for example). This syntax is recommended.
PrivateKeyCharacter string or Certificate variableName of Certificate variable to use or files of pem keys (to establish a connection by private key).
If this property is specified, an authentication by key is performed: only ..User, ..PrivateKey and ..PrivateKeyPassword are taken into account.
ClientIDCharacter stringIdentifier of client. This property must not be left empty.
PrivateKeyPasswordCharacter stringPassword of key file (for a connection by private key). ..PrivateKey corresponds to the private key to use.
UserPasswordCharacter stringUser password used for an authentication by password (..User corresponds to the user name).
OptionInteger constantConnection options. This property can correspond to the optionSSL constant for an SSL connection.
PortIntegerPort of MQTT server. This port correspondsn to 1883 by default (or 8883 for an SSL connection).
CleanSessionBoolean
  • True to clean the generic global parameters on the server,
  • False otherwise.
ConnectionTimeOutInteger ou DurationConnection time-out in seconds. This property can correspond to:
  • an integer corresponding to the number of seconds,
  • a Duration variable,
  • Versions 23 and later
    the direct indication of duration (10 s for example).
    New in version 23
    the direct indication of duration (10 s for example).
    the direct indication of duration (10 s for example).
UserCharacter stringName of user.


Note: These properties can be handled by using one of the following syntaxes:
  • <Variable Name>..<Property Name>
  • <Variable Name>.<Property Name>

Authentication mode

The authentication by key has priority over the authentication by password.
The authentication by key is attempted if:
  • the server supports this authentication mode.
  • ..PrivateKey is filled.
The authentication by password is attempted if:
  • the server supports this authentication mode.
  • ..UserPassword is filled.

Functions that handle the mqttSession variables

The following functions are used to handle the mqttSession variables:
Versions 22 and later
MQTTConnect
New in version 22
MQTTConnect
MQTTConnect
Used to connect to a MQTT server (also called "Broker").
Versions 22 and later
MQTTDisconnect
New in version 22
MQTTDisconnect
MQTTDisconnect
Used to disconnect from a MQTT server (also called "Broker").
Versions 22 and later
MQTTPublish
New in version 22
MQTTPublish
MQTTPublish
Publishes a message on the MQTT broker.
Versions 22 and later
MQTTSubscribe
New in version 22
MQTTSubscribe
MQTTSubscribe
Used to subscribe to a MQTT notification.
Versions 22 and later
MQTTUnsubscribe
New in version 22
MQTTUnsubscribe
MQTTUnsubscribe
Used to unsubscribe from a MQTT notification.
Versions 22 and later
MQTTUnsubscribeAll
New in version 22
MQTTUnsubscribeAll
MQTTUnsubscribeAll
Used to unsubscribe from all the existing subscriptions.
See also
Minimum required version
  • Version 22
This page is also available for…
Comments
Click [Add] to post a comment