-
- All Implemented Interfaces:
-
java.lang.Runnable,org.eclipse.paho.client.mqttv3.ICommsCallback
public class CommsCallback implements Runnable, ICommsCallback
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
Fields Modifier and Type Field Description public booleanrunningprivate ClientStateclientState
-
Method Summary
Modifier and Type Method Description voidsetClientState(ClientState clientState)voidstart(String threadName)Starts up the Callback thread. voidstop()Stops the callback thread. voidsetCallback(MqttCallback mqttCallback)voidrun()voidconnectionLost(MqttException cause)This method is called when the connection to the server is lost. voidfastReconnect()voidfireActionEvent(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. voidmessageArrived(MqttPublish sendMessage)This method is called when a message arrives on a topic. voidquiesce()Let the call back thread quiesce. booleanisQuiesced()voidasyncOperationComplete(MqttToken token)ThreadgetThread()Returns the thread used by this callback. -
-
Method Detail
-
setClientState
void setClientState(ClientState clientState)
-
stop
void stop()
Stops the callback thread. This call will block until stop has completed.
-
setCallback
void setCallback(MqttCallback mqttCallback)
-
run
void run()
-
connectionLost
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.
-
fastReconnect
void fastReconnect()
-
fireActionEvent
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.
-
messageArrived
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
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
boolean isQuiesced()
-
asyncOperationComplete
void asyncOperationComplete(MqttToken token)
-
-
-
-