Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public interface MqttListener

Receives the life cycle and the messages of an MqttClient. Every method is called on the Codename One EDT.

Methods

public abstract void connected()The broker accepted the connection (CONNACK with return code 0).
public abstract void messageArrived(String topic, byte[] payload, boolean retained)A message arrived for a subscription that has no listener of its own.
public abstract void connectionLost(String reason)The connection ended without a call to MqttClient.disconnect(): the transport failed, the broker refused the connection, a packet was malformed or the keep alive was not answered.

Method details

connected

public abstract void connected()
The broker accepted the connection (CONNACK with return code 0). Messages queued while disconnected are re-sent right after this call returns to the client.

messageArrived

public abstract void messageArrived(String topic, byte[] payload, boolean retained)
A message arrived for a subscription that has no listener of its own.

Parameters

topic String
the topic name the message was published to
payload byte[]
the message body
retained boolean
true when the broker sent it from its retained store

connectionLost

public abstract void connectionLost(String reason)
The connection ended without a call to MqttClient.disconnect(): the transport failed, the broker refused the connection, a packet was malformed or the keep alive was not answered.

Parameters

reason String
a human readable description