001/**
002 *
003 * Copyright 2003-2007 Jive Software.
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.jivesoftware.smack;
019
020/**
021 * Interface that allows for implementing classes to listen for connection closing
022 * and reconnection events. Listeners are registered with XMPPConnection objects.
023 *
024 * @see XMPPConnection#addConnectionListener
025 * @see XMPPConnection#removeConnectionListener
026 * 
027 * @author Matt Tucker
028 */
029public interface ConnectionListener {
030
031    /**
032     * TODO
033     * @param connection
034     */
035    public void connected(XMPPConnection connection);
036
037    /**
038     * TODO
039     * @param connection
040     */
041    public void authenticated(XMPPConnection connection);
042
043    /**
044     * Notification that the connection was closed normally or that the reconnection
045     * process has been aborted.
046     */
047    public void connectionClosed();
048
049    /**
050     * Notification that the connection was closed due to an exception. When
051     * abruptly disconnected it is possible for the connection to try reconnecting
052     * to the server.
053     *
054     * @param e the exception.
055     */
056    public void connectionClosedOnError(Exception e);
057    
058    /**
059     * The connection will retry to reconnect in the specified number of seconds.
060     * 
061     * @param seconds remaining seconds before attempting a reconnection.
062     */
063    public void reconnectingIn(int seconds);
064    
065    /**
066     * The connection has reconnected successfully to the server. Connections will
067     * reconnect to the server when the previous socket connection was abruptly closed.
068     */
069    public void reconnectionSuccessful();
070    
071    /**
072     * An attempt to connect to the server has failed. The connection will keep trying
073     * reconnecting to the server in a moment.
074     *
075     * @param e the exception that caused the reconnection to fail.
076     */
077    public void reconnectionFailed(Exception e);
078}