public class ReconnectionManager extends Object implements NetConnectivityListener
ReconnectionManager makes attempts to reconnect a broken XMPP
connection. Upon receiving reconnection request, reconnection is attempted
asynchronously in a separate thread and once connection is established, the
thread dies. Unless it's shutdown, the manager will continue to try to
establish a connection with server and negotiate a XMPP stream with it.
Each time reconnection attempt fails, the reconnection process is suspended
for a time calculated based upon back-off policy configured within
ReconnectionManager. While reconnecting, network availability on the
device is also taken into account. If device does not have network
connectivity, the reconnection process will wait until network is available
on device.
ReconnectionManager maintains a list of ReconnectionListeners
which it notifies at appropriate stages of the reconnection process.
| Constructor and Description |
|---|
ReconnectionManager(boolean connectivity) |
| Modifier and Type | Method and Description |
|---|---|
void |
addReconnectionListener(ReconnectionListener listener)
Add a
ReconnectionListener to the listener list maintaned by
ReconnectionManager |
void |
connected()
Call to indicate network connectivity has been established on the device
|
void |
disconnected()
Call to indicate that netwrok connectivity is lost on the device
|
Future<Boolean> |
reconnectAsync(XMPPConnection conn) |
public Future<Boolean> reconnectAsync(XMPPConnection conn)
public void connected()
NetConnectivityListenerconnected in interface NetConnectivityListenerpublic void disconnected()
NetConnectivityListenerdisconnected in interface NetConnectivityListenerpublic void addReconnectionListener(ReconnectionListener listener)
ReconnectionListener to the listener list maintaned by
ReconnectionManagerlistener - ReconnectionListener to be added to listCopyright © 2019. All rights reserved.