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 * Notification that the connection has been successfully connected to the remote endpoint (e.g. the XMPP server). 033 * <p> 034 * Note that the connection is likely not yet authenticated and therefore only limited operations like registering 035 * an account may be possible. 036 * </p> 037 * 038 * @param connection the XMPPConnection which successfully connected to its endpoint. 039 */ 040 void connected(XMPPConnection connection); 041 042 /** 043 * Notification that the connection has been authenticated. 044 * 045 * @param connection the XMPPConnection which successfully authenticated. 046 * @param resumed true if a previous XMPP session's stream was resumed. 047 */ 048 void authenticated(XMPPConnection connection, boolean resumed); 049 050 /** 051 * Notification that the connection was closed normally. 052 */ 053 void connectionClosed(); 054 055 /** 056 * Notification that the connection was closed due to an exception. When 057 * abruptly disconnected it is possible for the connection to try reconnecting 058 * to the server. 059 * 060 * @param e the exception. 061 */ 062 void connectionClosedOnError(Exception e); 063 064}