X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fnet%2Fpterodactylus%2Ffcp%2Fhighlevel%2FHighLevelClient.java;h=9fd36fdefd716ed2a8d84ddd7492543633fecbd9;hb=930a13cd3640422a0fd23e2952cacf798286f0bc;hp=6149adfd39c3e04cc98aa8cf64b6a6fc10da27c2;hpb=ce478696a8689472c1bd99e4d79eef4d822e4eff;p=jFCPlib.git
diff --git a/src/net/pterodactylus/fcp/highlevel/HighLevelClient.java b/src/net/pterodactylus/fcp/highlevel/HighLevelClient.java
index 6149adf..9fd36fd 100644
--- a/src/net/pterodactylus/fcp/highlevel/HighLevelClient.java
+++ b/src/net/pterodactylus/fcp/highlevel/HighLevelClient.java
@@ -232,10 +232,14 @@ public class HighLevelClient {
/**
* Notifies all listeners that a client has disconnected.
+ *
+ * @param throwable
+ * The exception that caused the disconnect, or null
+ * if there was no exception
*/
- private void fireClientDisconnected() {
+ private void fireClientDisconnected(Throwable throwable) {
for (HighLevelClientListener highLevelClientListener: highLevelClientListeners) {
- highLevelClientListener.clientDisconnected(this);
+ highLevelClientListener.clientDisconnected(this, throwable);
}
}
@@ -278,8 +282,7 @@ public class HighLevelClient {
* Disconnects the client from the node.
*/
public void disconnect() {
- fcpConnection.close();
- fireClientDisconnected();
+ disconnect(null);
}
/**
@@ -434,6 +437,19 @@ public class HighLevelClient {
}
/**
+ * Disconnects the client from the node, handing the given Throwable to
+ * {@link #fireClientDisconnected(Throwable)}.
+ *
+ * @param throwable
+ * The exception that caused the disconnect, or null
+ * if there was no exception
+ */
+ private void disconnect(Throwable throwable) {
+ fcpConnection.close();
+ fireClientDisconnected(throwable);
+ }
+
+ /**
* FCP listener for {@link HighLevelClient}.
*
* @author David âBombeâ Roden <bombe@freenetproject.org>
@@ -608,15 +624,16 @@ public class HighLevelClient {
//
/**
- * @see net.pterodactylus.fcp.FcpListener#connectionClosed(net.pterodactylus.fcp.FcpConnection)
+ * @see net.pterodactylus.fcp.FcpListener#connectionClosed(net.pterodactylus.fcp.FcpConnection,
+ * Throwable)
*/
@SuppressWarnings("synthetic-access")
- public void connectionClosed(FcpConnection fcpConnection) {
+ public void connectionClosed(FcpConnection fcpConnection, Throwable throwable) {
if (fcpConnection != HighLevelClient.this.fcpConnection) {
return;
}
cancelIdentifier(null);
- disconnect();
+ disconnect(throwable);
}
/**