From: David ‘Bombe’ Roden Date: Sat, 12 Apr 2008 22:07:22 +0000 (+0000) Subject: add listener method for connection aborts X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=8064631576fc52669f2f5efb28235d32f39407a6;p=jSite2.git add listener method for connection aborts git-svn-id: http://trooper/svn/projects/jSite/trunk@748 c3eda9e8-030b-0410-8277-bc7414b0a119 --- diff --git a/src/net/pterodactylus/util/fcp/FcpAdapter.java b/src/net/pterodactylus/util/fcp/FcpAdapter.java index c2f7fbf..9b858cf 100644 --- a/src/net/pterodactylus/util/fcp/FcpAdapter.java +++ b/src/net/pterodactylus/util/fcp/FcpAdapter.java @@ -267,4 +267,11 @@ public class FcpAdapter implements FcpListener { /* empty. */ } + /** + * {@inheritDoc} + */ + public void connectionClosed(FcpConnection fcpConnection) { + /* empty. */ + } + } diff --git a/src/net/pterodactylus/util/fcp/FcpConnection.java b/src/net/pterodactylus/util/fcp/FcpConnection.java index f08c8cb..bb0ac40 100644 --- a/src/net/pterodactylus/util/fcp/FcpConnection.java +++ b/src/net/pterodactylus/util/fcp/FcpConnection.java @@ -610,6 +610,17 @@ public class FcpConnection { } } + /** + * Notifies all listeners that the connection to the node was closed. + * + * @see FcpListener#connectionClosed(FcpConnection) + */ + private void fireConnectionClosed() { + for (FcpListener fcpListener: fcpListeners) { + fcpListener.connectionClosed(this); + } + } + // // ACTIONS // @@ -767,6 +778,7 @@ public class FcpConnection { Closer.close(remoteOutputStream); Closer.close(remoteSocket); connectionHandler = null; + fireConnectionClosed(); } // diff --git a/src/net/pterodactylus/util/fcp/FcpListener.java b/src/net/pterodactylus/util/fcp/FcpListener.java index 65baa36..eafb5aa 100644 --- a/src/net/pterodactylus/util/fcp/FcpListener.java +++ b/src/net/pterodactylus/util/fcp/FcpListener.java @@ -394,4 +394,14 @@ public interface FcpListener extends EventListener { */ public void receivedMessage(FcpConnection fcpConnection, FcpMessage fcpMessage); + /** + * Notifies a listener that a connection was closed. A closed connection can + * be reestablished by calling {@link FcpConnection#connect()} on the same + * object again. + * + * @param fcpConnection + * The connection that was closed. + */ + public void connectionClosed(FcpConnection fcpConnection); + }