net.sf.xenqtt.client
Interface MqttClientListener

All Known Subinterfaces:
AsyncClientListener

public interface MqttClientListener

Implement this interface to use SyncMqttClient. The client will invoke the methods in this interface when a published message is received. A single instance of this interface may be used with multiple clients.


Field Summary
static MqttClientListener NULL_LISTENER
          Use this listener when you want to ignore all client events including received messages.
 
Method Summary
 void disconnected(MqttClient client, Throwable cause, boolean reconnecting)
          Called when the connection to the broker is lost either unintentionally or because the client requested the disconnect.
 void publishReceived(MqttClient client, PublishMessage message)
          Called when a published message is received from the broker.
 

Field Detail

NULL_LISTENER

static final MqttClientListener NULL_LISTENER
Use this listener when you want to ignore all client events including received messages. Any received messages will be ack'd.

Method Detail

publishReceived

void publishReceived(MqttClient client,
                     PublishMessage message)
Called when a published message is received from the broker. You should always call ack() when you are done processing the message. This is not required if the QoS is QoS.AT_MOST_ONCE but it is a good practice to always call it.

Parameters:
client - The client that received the message
message - The message that was published

disconnected

void disconnected(MqttClient client,
                  Throwable cause,
                  boolean reconnecting)
Called when the connection to the broker is lost either unintentionally or because the client requested the disconnect.

Parameters:
client - The client that was disconnected
cause - The exception that caused the client to disconnect. Null if there was no exception.
reconnecting - True if the client will attempt to reconnect. False if either all reconnect attempts have failed or the disconnect was not because of an exception.


Copyright © 2013. All Rights Reserved.