org.jivesoftware.smack
Class ReconnectionManager

java.lang.Object
  extended by org.jivesoftware.smack.ReconnectionManager
All Implemented Interfaces:
ConnectionListener

public class ReconnectionManager
extends java.lang.Object
implements ConnectionListener

Handles the automatic reconnection process. Every time a connection is dropped without the application explictly closing it, the manager automatically tries to reconnect to the server.

The reconnection mechanism will try to reconnect periodically:

  1. For the first minute it will attempt to connect once every ten seconds.
  2. For the next five minutes it will attempt to connect once a minute.
  3. If that fails it will indefinitely try to connect once every five minutes.

Author:
Francisco Vives

Method Summary
 void connectionClosed()
          Notification that the connection was closed normally or that the reconnection process has been aborted.
 void connectionClosedOnError(java.lang.Exception e)
          Notification that the connection was closed due to an exception.
 void reconnectingIn(int seconds)
          The connection will retry to reconnect in the specified number of seconds.
 void reconnectionFailed(java.lang.Exception e)
          An attempt to connect to the server has failed.
 void reconnectionSuccessful()
          The connection has successfull gotten connected.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

connectionClosed

public void connectionClosed()
Description copied from interface: ConnectionListener
Notification that the connection was closed normally or that the reconnection process has been aborted.

Specified by:
connectionClosed in interface ConnectionListener

connectionClosedOnError

public void connectionClosedOnError(java.lang.Exception e)
Description copied from interface: ConnectionListener
Notification that the connection was closed due to an exception. When abruptly disconnected it is possible for the connection to try reconnecting to the server.

Specified by:
connectionClosedOnError in interface ConnectionListener
Parameters:
e - the exception.

reconnectingIn

public void reconnectingIn(int seconds)
Description copied from interface: ConnectionListener
The connection will retry to reconnect in the specified number of seconds.

Specified by:
reconnectingIn in interface ConnectionListener
Parameters:
seconds - remaining seconds before attempting a reconnection.

reconnectionFailed

public void reconnectionFailed(java.lang.Exception e)
Description copied from interface: ConnectionListener
An attempt to connect to the server has failed. The connection will keep trying reconnecting to the server in a moment.

Specified by:
reconnectionFailed in interface ConnectionListener
Parameters:
e - the exception that caused the reconnection to fail.

reconnectionSuccessful

public void reconnectionSuccessful()
The connection has successfull gotten connected.

Specified by:
reconnectionSuccessful in interface ConnectionListener