Public Sub ConnectTo(Host As String, Name As String)
currentName = Name
isServer = Host = "127.0.0.1"
If isServer Then
If brokerStarted = False Then
broker.Start
brokerStarted = True
End If
users.Clear
' Host = "127.0.0.1"
End If
If connected Then client.Close
client.Initialize("client", $"ssl://${Host}:${port}"$, "android" & Rnd(1, 10000000))
Dim mo As MqttConnectOptions
mo.Initialize("yves1", "lespommes")
TrustAll(mo) '<<<<<<<<<<<<<<<<<<<--------------'
'this message will be sent if the client is disconnected unexpectedly.
mo.SetLastWill("all/disconnect", serializator.ConvertObjectToBytes(currentName), 0, False)
client.Connect2(mo)
End Sub