SetUserName

The username, password, and SSL options are used for client authentication with the MQTT broker. These should be set before calling the oMQTT.Connect function.

Group:  MQTT Object

Type: Command

Syntax:   oMQTT.SetUserName( Username)

Username      (String) The text string that authenticates the username with the MQTT broker

Example:

Private Sub Form_Load()

On Error Resume Next

App.Balloon("Connecting...", -1)

Set moClient = New MQTT

If Not moClient.Connect("tcp://localhost:1883", "RFgen_Subscriber_Client_001", 4000) Then

App.MsgBox("Error: " & moClient.Error)

Exit Sub

End If

' New connect will disconnect old client

If Not moClient.Connect("tcp://localhost:1883", "RFgen_Subscriber_Client_002", 4000) Then

App.MsgBox("There was an error initializing client")

Exit Sub

End If

moClient.SetLWT("LWT Topic", "Here's a payload")

moClient.SetPassword("09287Tzzx")

moClient.SetUsername("Sam")

moClient.SSL_SetPrivateKey("/uhhh")

App.Balloon("", 0)

End Sub

 

Versions Supported:      RFgen 5.1.1.35 and 5.2.3 and newer.