Android Question jMQTT read retained status

Discussion in 'Android Questions' started by michw, May 29, 2019.

  1. michw

    michw Member Licensed User

    I have a question, can I use the jMQTT library when I get a message from the server to read ststus of the Retained flag?
    The point is to know that the received message is out of date.
  2. Erel

    Erel Administrator Staff Member Licensed User

    You can do it by creating your own callback with JavaObject.

    Untested code:
    Dim client As JavaObject = mqtt
       client = client.GetField(
    Dim event As Object = client.CreateEventFromUI("org.eclipse.paho.client.mqttv3.MqttCallback""callback"Null)

    Sub Callback_Event (MethodName As String, Args() As Object) As Object
    Select MethodName
    Case "messageArrived"
    Dim topic As String = Args(0)
    Dim MqttMessage As JavaObject = Args(1)
    Case "connectionLost"
    Log("Connection lost")
    Case "deliveryComplete"
    End Select
    Return Null
    End Sub
    MqttMessage API:
    lemonisdead likes this.
  3. michw

    michw Member Licensed User

    Thank you,
    I will test whether it works
  4. michw

    michw Member Licensed User

    It's work perfect! Thanks Erel
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice