1/** 2 * $RCSfile$ 3 * $Revision$ 4 * $Date$ 5 * 6 * Copyright 2003-2007 Jive Software. 7 * 8 * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 21package org.jivesoftware.smack; 22 23/** 24 * Interface that allows for implementing classes to listen for connection closing 25 * and reconnection events. Listeners are registered with Connection objects. 26 * 27 * @see Connection#addConnectionListener 28 * @see Connection#removeConnectionListener 29 * 30 * @author Matt Tucker 31 */ 32public interface ConnectionListener { 33 34 /** 35 * Notification that the connection was closed normally or that the reconnection 36 * process has been aborted. 37 */ 38 public void connectionClosed(); 39 40 /** 41 * Notification that the connection was closed due to an exception. When 42 * abruptly disconnected it is possible for the connection to try reconnecting 43 * to the server. 44 * 45 * @param e the exception. 46 */ 47 public void connectionClosedOnError(Exception e); 48 49 /** 50 * The connection will retry to reconnect in the specified number of seconds. 51 * 52 * @param seconds remaining seconds before attempting a reconnection. 53 */ 54 public void reconnectingIn(int seconds); 55 56 /** 57 * The connection has reconnected successfully to the server. Connections will 58 * reconnect to the server when the previous socket connection was abruptly closed. 59 */ 60 public void reconnectionSuccessful(); 61 62 /** 63 * An attempt to connect to the server has failed. The connection will keep trying 64 * reconnecting to the server in a moment. 65 * 66 * @param e the exception that caused the reconnection to fail. 67 */ 68 public void reconnectionFailed(Exception e); 69}