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

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

public class ConnectActionListener
extends Object
implements IMqttActionListener

This class handles the connection of the AsyncClient to one of the available URLs.

The URLs are supplied as either the singleton when the client is created, or as a list in the connect options.

This class uses its own onSuccess and onFailure callbacks in preference to the user supplied callbacks.

An attempt is made to connect to each URL in the list until either a connection attempt succeeds or all the URLs have been tried

If a connection succeeds then the users token is notified and the users onSuccess callback is called.

If a connection fails then another URL in the list is attempted, otherwise the users token is notified and the users onFailure callback is called


Constructor Summary
ConnectActionListener(MqttAsyncClient client, MqttClientPersistence persistence, ClientComms comms, MqttConnectOptions options, MqttToken userToken, Object userContext, IMqttActionListener userCallback)
           
 
Method Summary
 void connect()
          The connect failed, so try the next URI on the list.
 void onFailure(IMqttToken token, Throwable exception)
          The connect failed, so try the next URI on the list.
 void onSuccess(IMqttToken token)
          If the connect succeeded then call the users onSuccess callback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectActionListener

public ConnectActionListener(MqttAsyncClient client,
                             MqttClientPersistence persistence,
                             ClientComms comms,
                             MqttConnectOptions options,
                             MqttToken userToken,
                             Object userContext,
                             IMqttActionListener userCallback)
Parameters:
persistence -
client -
comms -
options -
userToken -
userContext -
userCallback -
Method Detail

onSuccess

public void onSuccess(IMqttToken token)
If the connect succeeded then call the users onSuccess callback

Specified by:
onSuccess in interface IMqttActionListener
Parameters:
token -

onFailure

public void onFailure(IMqttToken token,
                      Throwable exception)
The connect failed, so try the next URI on the list. If there are no more URIs, then fail the overall connect.

Specified by:
onFailure in interface IMqttActionListener
Parameters:
token -
exception -

connect

public void connect()
             throws MqttPersistenceException
The connect failed, so try the next URI on the list. If there are no more URIs, then fail the overall connect.

Throws:
MqttPersistenceException


Copyright © 2013. All Rights Reserved.