Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private broker As MQTTBrokerExtended
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
broker.Initialize(1883, broker.AUTHENTICATION_NO, False, "broker")
broker.Start
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Private Sub Button1_Click
xui.MsgboxAsync("Hello world!", "B4X")
End Sub
Private Sub broker_Publish(ClientID As String, Username As String, QOS As String, TopicName As String, Message() As Byte, IsDupFlag As Boolean, IsRetainFlag As Boolean)
' Someone published a message
Log(BytesToString(Message, 0, Message.Length, "UTF-8"))
' If SubExists(mCallBack, $"${mEventName}_NewMessage"$) Then
' CallSubDelayed3(mCallBack, $"${mEventName}_NewMessage"$, TopicName, BytesToString(Message, 0, Message.Length, "utf8"))
' End If
End Sub