public class ConnectActionListener extends java.lang.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 and Description |
---|
ConnectActionListener(MqttAsyncClient client,
MqttClientPersistence persistence,
ClientComms comms,
MqttConnectOptions options,
MqttToken userToken,
java.lang.Object userContext,
IMqttActionListener userCallback,
boolean reconnect) |
Modifier and Type | Method and Description |
---|---|
void |
connect()
Start the connect processing
|
void |
onFailure(IMqttToken token,
java.lang.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
|
void |
setMqttCallbackExtended(MqttCallbackExtended mqttCallbackExtended)
Set the MqttCallbackExtened callback to receive connectComplete callbacks
|
public ConnectActionListener(MqttAsyncClient client, MqttClientPersistence persistence, ClientComms comms, MqttConnectOptions options, MqttToken userToken, java.lang.Object userContext, IMqttActionListener userCallback, boolean reconnect)
persistence
- client
- comms
- options
- userToken
- userContext
- userCallback
- public void onSuccess(IMqttToken token)
onSuccess
in interface IMqttActionListener
token
- public void onFailure(IMqttToken token, java.lang.Throwable exception)
onFailure
in interface IMqttActionListener
token
- exception
- public void connect() throws MqttPersistenceException
MqttPersistenceException
public void setMqttCallbackExtended(MqttCallbackExtended mqttCallbackExtended)
mqttCallbackExtended
-