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

java.lang.Object
  extended by org.eclipse.paho.client.mqttv3.internal.CommsTokenStore

public class CommsTokenStore
extends Object

Provides a "token" based system for storing and tracking actions across multiple threads. When a message is sent, a token is associated with the message and saved using the saveToken(MqttToken, MqttWireMessage) method. Anyone interested in tacking the state can call one of the wait methods on the token or using the asynchronous listener callback method on the operation. The CommsReceiver class, on another thread, reads responses back from the network. It uses the response to find the relevant token, which it can then notify. Note: Ping, connect and disconnect do not have a unique message id as only one outstanding request of each type is allowed to be outstanding


Constructor Summary
CommsTokenStore(String logContext)
           
 
Method Summary
 void clear()
          Empties the token store without notifying any of the tokens.
 int count()
           
 MqttDeliveryToken[] getOutstandingDelTokens()
           
 Vector getOutstandingTokens()
           
 MqttToken getToken(MqttWireMessage message)
          Based on the message type that has just been received return the associated token from the token store or null if one does not exist.
 MqttToken getToken(String key)
           
 void open()
           
protected  void quiesce(MqttException quiesceResponse)
           
 MqttToken removeToken(MqttWireMessage message)
           
 MqttToken removeToken(String key)
           
protected  MqttDeliveryToken restoreToken(MqttPublish message)
          Restores a token after a client restart.
protected  void saveToken(MqttToken token, MqttWireMessage message)
           
protected  void saveToken(MqttToken token, String key)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CommsTokenStore

public CommsTokenStore(String logContext)
Method Detail

getToken

public MqttToken getToken(MqttWireMessage message)
Based on the message type that has just been received return the associated token from the token store or null if one does not exist.

Parameters:
message - whose token is to be returned
Returns:
token for the requested message

getToken

public MqttToken getToken(String key)

removeToken

public MqttToken removeToken(MqttWireMessage message)

removeToken

public MqttToken removeToken(String key)

restoreToken

protected MqttDeliveryToken restoreToken(MqttPublish message)
Restores a token after a client restart. This method could be called for a SEND of CONFIRM, but either way, the original SEND is what's needed to re-build the token.


saveToken

protected void saveToken(MqttToken token,
                         MqttWireMessage message)
                  throws MqttException
Throws:
MqttException

saveToken

protected void saveToken(MqttToken token,
                         String key)

quiesce

protected void quiesce(MqttException quiesceResponse)

open

public void open()

getOutstandingDelTokens

public MqttDeliveryToken[] getOutstandingDelTokens()

getOutstandingTokens

public Vector getOutstandingTokens()

clear

public void clear()
Empties the token store without notifying any of the tokens.


count

public int count()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.