Android Question MqttChat auto discover Example as [B4XPages] but only one Activity in B4XPages

a6000000

Member
Licensed User
Longtime User
MqttChat auto discover Example :
https://www.b4x.com/android/forum/threads/mqtt-chat-with-auto-discovery.75713/

B4X:
 Private Sub client_MessageArrived (Topic As String, Payload() As Byte)
    Dim receivedObject As Object = serializator.ConvertBytesToObject(Payload)
    If Topic = "all/connect" Or Topic = "all/disconnect" Then
        'new client has connected or disconnected
        Dim newUser As String = receivedObject
        If isServer Then
            Log($"${Topic}: ${newUser}"$)
            Dim index As Int = users.IndexOf(newUser)
            If Topic.EndsWith("connect") And index = -1 Then users.Add(newUser)
            If Topic.EndsWith("disconnect") And index >= 0 Then users.RemoveAt(index)
            client.Publish2("all/users", serializator.ConvertObjectToBytes(users), 0, False)
        End If
    Else if Topic = "all/users" Then
        Dim newUsers As List = receivedObject
        CallSubDelayed2(Chat, "NewUsers", newUsers) 'this will start the chat activity if it wasn't started yet.
        '// in B4XPage I have: CallSubDelayed2(ChatPage, "NewUsers", newUsers) 
    Else
        Dim m As Message = receivedObject
        CallSub2(Chat, "NewMessage", m)
    End If
       
End Sub


Line 15:
CallSubDelayed2(Chat, "NewUsers", newUsers) 'this will start the chat activity if it wasn't started yet.


'this will start the chat activity if it wasn't started yet.



I have transferred the example to B4 XPages. So I have now a B4XPage Chat , not a new Activity Chat.

Line 15: Chat Activity should be started at this point.

I try: CallSubDelayed2 (ChatPage, "NewUsers", newUsers)

call the sub in Chat B4X class is not enough. There is only one Activity in B4 Xpages, what do I start instead of the Chat Activity?
 
Top