mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-23 11:07:57 +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:
parent
a669771a4e
commit
3c4441db96
1 changed files with 16 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
package org.jivesoftware.smack.debugger;
|
package org.jivesoftware.smack.debugger;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.ConnectionListener;
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
|
@ -26,6 +27,7 @@ public class ConsoleDebugger implements SmackDebugger {
|
||||||
private XMPPConnection connection = null;
|
private XMPPConnection connection = null;
|
||||||
|
|
||||||
private PacketListener listener = null;
|
private PacketListener listener = null;
|
||||||
|
private ConnectionListener connListener = null;
|
||||||
|
|
||||||
private Writer writer;
|
private Writer writer;
|
||||||
private Reader reader;
|
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) {
|
public void userHasLogged(String user) {
|
||||||
|
@ -89,6 +102,9 @@ public class ConsoleDebugger implements SmackDebugger {
|
||||||
+ connection.getPort();
|
+ connection.getPort();
|
||||||
title += "/" + StringUtils.parseResource(user);
|
title += "/" + StringUtils.parseResource(user);
|
||||||
System.out.println(title);
|
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() {
|
public Reader getReader() {
|
||||||
|
|
Loading…
Reference in a new issue