org.eclipse.paho.client.mqttv3.internal
Class CommsCallback

java.lang.Object
  extended by org.eclipse.paho.client.mqttv3.internal.CommsCallback
All Implemented Interfaces:
Runnable

public class CommsCallback
extends Object
implements Runnable

Bridge between Receiver and the external API. This class gets called by Receiver, and then converts the comms-centric MQTT message objects into ones understood by the external API.


Field Summary
 boolean running
           
 
Method Summary
 void asyncOperationComplete(MqttToken token)
           
 void connectionLost(MqttException cause)
          This method is called when the connection to the server is lost.
 void fireActionEvent(MqttToken token)
          An action has completed - if a completion listener has been set on the token then invoke it with the outcome of the action.
protected  Thread getThread()
          Returns the thread used by this callback.
 boolean isQuiesced()
           
 void messageArrived(MqttPublish sendMessage)
          This method is called when a message arrives on a topic.
 void quiesce()
          Let the call back thread quiesce.
 void run()
           
 void setCallback(MqttCallback mqttCallback)
           
 void setClientState(ClientState clientState)
           
 void start(String threadName)
          Starts up the Callback thread.
 void stop()
          Stops the callback thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

running

public boolean running
Method Detail

setClientState

public void setClientState(ClientState clientState)

start

public void start(String threadName)
Starts up the Callback thread.


stop

public void stop()
Stops the callback thread. This call will block until stop has completed.


setCallback

public void setCallback(MqttCallback mqttCallback)

run

public void run()
Specified by:
run in interface Runnable

connectionLost

public void connectionLost(MqttException cause)
This method is called when the connection to the server is lost. If there is no cause then it was a clean disconnect. The connectionLost callback will be invoked if registered and run on the thread that requested shutdown e.g. receiver or sender thread. If the request was a user initiated disconnect then the disconnect token will be notified.

Parameters:
cause - the reason behind the loss of connection.

fireActionEvent

public void fireActionEvent(MqttToken token)
An action has completed - if a completion listener has been set on the token then invoke it with the outcome of the action.

Parameters:
token -

messageArrived

public void messageArrived(MqttPublish sendMessage)
This method is called when a message arrives on a topic. Messages are only added to the queue for inbound messages if the client is not quiescing.

Parameters:
sendMessage - the MQTT SEND message.

quiesce

public void quiesce()
Let the call back thread quiesce. Prevent new inbound messages being added to the process queue and let existing work quiesce. (until the thread is told to shutdown).


isQuiesced

public boolean isQuiesced()

asyncOperationComplete

public void asyncOperationComplete(MqttToken token)

getThread

protected Thread getThread()
Returns the thread used by this callback.



Copyright © 2013. All Rights Reserved.