X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Ffcp%2FFcpConnection.java;h=d1a1be7cb17d4ea03847568f46ed3f592c4eb47c;hb=c1710356b299b5d3eebd019e69e370ac6f7b81b5;hp=5757d617a95dc36985d4e7e7faadfc07a933b1f4;hpb=b191d20a7bafe31ccf0d74962f73c5cd94c37a27;p=jFCPlib.git
diff --git a/src/net/pterodactylus/fcp/FcpConnection.java b/src/net/pterodactylus/fcp/FcpConnection.java
index 5757d61..d1a1be7 100644
--- a/src/net/pterodactylus/fcp/FcpConnection.java
+++ b/src/net/pterodactylus/fcp/FcpConnection.java
@@ -649,11 +649,14 @@ public class FcpConnection implements Closeable {
/**
* Notifies all listeners that the connection to the node was closed.
*
- * @see FcpListener#connectionClosed(FcpConnection)
+ * @param throwable
+ * The exception that caused the disconnect, or null
+ * if there was no exception
+ * @see FcpListener#connectionClosed(FcpConnection, Throwable)
*/
- private void fireConnectionClosed() {
+ private void fireConnectionClosed(Throwable throwable) {
for (FcpListener fcpListener: fcpListeners) {
- fcpListener.connectionClosed(this);
+ fcpListener.connectionClosed(this, throwable);
}
}
@@ -696,14 +699,7 @@ public class FcpConnection implements Closeable {
* does nothing.
*/
public void close() {
- if (connectionHandler == null) {
- return;
- }
- logger.info("disconnectingâ¦");
- FcpUtils.close(remoteSocket);
- connectionHandler.stop();
- connectionHandler = null;
- fireConnectionClosed();
+ handleDisconnect(null);
}
/**
@@ -823,13 +819,20 @@ public class FcpConnection implements Closeable {
/**
* Handles a disconnect from the node.
+ *
+ * @param throwable
+ * The exception that caused the disconnect, or null
+ * if there was no exception
*/
- synchronized void handleDisconnect() {
+ synchronized void handleDisconnect(Throwable throwable) {
FcpUtils.close(remoteInputStream);
FcpUtils.close(remoteOutputStream);
FcpUtils.close(remoteSocket);
- connectionHandler = null;
- fireConnectionClosed();
+ if (connectionHandler != null) {
+ connectionHandler.stop();
+ connectionHandler = null;
+ fireConnectionClosed(throwable);
+ }
}
//