1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-26 16:22:06 +01:00

Added logging when connection is closed.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2499 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2005-06-08 02:55:09 +00:00 committed by gaston
parent a669771a4e
commit 3c4441db96

View file

@ -1,5 +1,6 @@
package org.jivesoftware.smack.debugger;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.Packet;
@ -26,6 +27,7 @@ public class ConsoleDebugger implements SmackDebugger {
private XMPPConnection connection = null;
private PacketListener listener = null;
private ConnectionListener connListener = null;
private Writer writer;
private Reader reader;
@ -76,6 +78,17 @@ public class ConsoleDebugger implements SmackDebugger {
}
}
};
connListener = new ConnectionListener() {
public void connectionClosed() {
System.out.println("Connection closed (" + connection.hashCode() + ")");
}
public void connectionClosedOnError(Exception e) {
System.out.println("Connection closed due to an exception (" + connection.hashCode() + ")");
e.printStackTrace();
}
};
}
public void userHasLogged(String user) {
@ -89,6 +102,9 @@ public class ConsoleDebugger implements SmackDebugger {
+ connection.getPort();
title += "/" + StringUtils.parseResource(user);
System.out.println(title);
// Add the connection listener to the connection so that the debugger can be notified
// whenever the connection is closed.
connection.addConnectionListener(connListener);
}
public Reader getReader() {