1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-10 01:29:38 +02:00

Added ConnectionListener support.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1983 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2003-07-09 16:05:43 +00:00 committed by mtucker
parent ed14b2a204
commit b25380282c
3 changed files with 121 additions and 3 deletions

View file

@ -485,6 +485,34 @@ public class XMPPConnection {
return packetReader.createPacketCollector(packetFilter);
}
/**
* Adds a connection listener to this connection that will be notified when
* the connection closes or fails.
*
* @param connectionListener a connection listener.
*/
public void addConnectionListener(ConnectionListener connectionListener) {
if (connectionListener == null) {
return;
}
synchronized (packetReader.connectionListeners) {
if (!packetReader.connectionListeners.contains(connectionListener)) {
packetReader.connectionListeners.add(connectionListener);
}
}
}
/**
* Removes a connection listener from this connection.
*
* @param connectionListener a connection listener.
*/
public void removeConnectionListener(ConnectionListener connectionListener) {
synchronized (packetReader.connectionListeners) {
packetReader.connectionListeners.remove(connectionListener);
}
}
/**
* Initializes the connection by creating a packet reader and writer and opening a
* XMPP stream to the server.