B4J Question [B4J] jMQTTBroker v2 modified by teddybear

aeric

Expert
Licensed User
Longtime User
Hi @teddybear and fellow members,

Refer to this library:

I want to know:
  1. Is this a replacement of jMqttBroker v1.04 and v2.02?
  2. Does this mean I no longer need to add an MqttClient to get the events like Connected, Disconnected, MessageArrived?
  3. Is this library still work if use together with MqttClient library?
  4. Which version of MqttClient library is supported for B4A and B4J? version 1.26?
 
Solution
Hi @teddybear and fellow members,

Refer to this library:

I want to know:
  1. Is this a replacement of jMqttBroker v1.04 and v2.02?
  2. Does this mean I no longer need to add an MqttClient to get the events like Connected, Disconnected, MessageArrived?
  3. Is this library still work if use together with MqttClient library?
  4. Which version of MqttClient library is supported for B4A and B4J? version 1.26?
1.No, it just added onConnect and onDisconnect events for jMqttBroker2.
2.No, it's only on broker side.
3.Yes
4.Version 1.26 is supported.

teddybear

Well-Known Member
Licensed User
Hi @teddybear and fellow members,

Refer to this library:

I want to know:
  1. Is this a replacement of jMqttBroker v1.04 and v2.02?
  2. Does this mean I no longer need to add an MqttClient to get the events like Connected, Disconnected, MessageArrived?
  3. Is this library still work if use together with MqttClient library?
  4. Which version of MqttClient library is supported for B4A and B4J? version 1.26?
1.No, it just added onConnect and onDisconnect events for jMqttBroker2.
2.No, it's only on broker side.
3.Yes
4.Version 1.26 is supported.
 
Upvote 0
Solution

aeric

Expert
Licensed User
Longtime User
Is the following code provided by Erel replacing:
B4X:
broker.Start

Dim server As JavaObject = Broker.As(JavaObject).GetField("server")
Dim pck As String = GetType(Me) & "$MyHandler"
Dim handler As JavaObject handler.InitializeNewInstance(pck, Array(Me))
Dim handlers As List = Array(handler) server.RunMethod("startServer", Array(Broker.As(JavaObject).GetField("config"), handlers))
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Is the following code provided by Erel replacing:
B4X:
broker.Start
Yes, the example is from Erel's code
Actually, you also add the handler dynamically after the broker started
 
Last edited:
Upvote 0

teddybear

Well-Known Member
Licensed User
Actually, you also add the handler dynamically after the broker started
Another way to add Interceptor.

B4X:
    Broker.Initialize("broker", 51042)
    Broker.Start
    Dim server As JavaObject = Broker.As(JavaObject).GetField("server")
    Dim pck As String = GetType(Me) & "$MyHandler"
    Dim handler As JavaObject
    handler.InitializeNewInstance(pck, Array(Me))
    server.RunMethod("addInterceptHandler", Array(handler))
 
Upvote 0
Top