From 0a4d1ff98574325df37f7cbb6b0655e86dd0cef4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 9 Apr 2008 10:01:28 +0000 Subject: [PATCH] added SSKKeypair message git-svn-id: http://trooper/svn/projects/jSite/trunk@657 c3eda9e8-030b-0410-8277-bc7414b0a119 --- src/net/pterodactylus/util/fcp/FcpAdapter.java | 9 +++++++++ src/net/pterodactylus/util/fcp/FcpConnection.java | 18 +++++++++++++++++- src/net/pterodactylus/util/fcp/FcpListener.java | 11 +++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/net/pterodactylus/util/fcp/FcpAdapter.java b/src/net/pterodactylus/util/fcp/FcpAdapter.java index 9a70d0f..65ab77b 100644 --- a/src/net/pterodactylus/util/fcp/FcpAdapter.java +++ b/src/net/pterodactylus/util/fcp/FcpAdapter.java @@ -5,6 +5,7 @@ package net.pterodactylus.util.fcp; import net.pterodactylus.util.fcp.message.CloseConnectionDuplicateClientName; import net.pterodactylus.util.fcp.message.NodeHello; +import net.pterodactylus.util.fcp.message.SSKKeypair; /** * Adapter for {@link FcpListener}. @@ -31,6 +32,14 @@ public class FcpAdapter implements FcpListener { } /** + * @see net.pterodactylus.util.fcp.FcpListener#receivedSSKKeypair(net.pterodactylus.util.fcp.FcpConnection, + * net.pterodactylus.util.fcp.message.SSKKeypair) + */ + public void receivedSSKKeypair(FcpConnection fcpConnection, SSKKeypair sskKeypair) { + /* empty. */ + } + + /** * @see net.pterodactylus.util.fcp.FcpListener#receivedMessage(net.pterodactylus.util.fcp.FcpConnection, * net.pterodactylus.util.fcp.FcpMessage) */ diff --git a/src/net/pterodactylus/util/fcp/FcpConnection.java b/src/net/pterodactylus/util/fcp/FcpConnection.java index 4582eca..846e135 100644 --- a/src/net/pterodactylus/util/fcp/FcpConnection.java +++ b/src/net/pterodactylus/util/fcp/FcpConnection.java @@ -30,6 +30,7 @@ import java.util.List; import net.pterodactylus.util.fcp.message.CloseConnectionDuplicateClientName; import net.pterodactylus.util.fcp.message.NodeHello; +import net.pterodactylus.util.fcp.message.SSKKeypair; import net.pterodactylus.util.io.Closer; /** @@ -170,6 +171,19 @@ public class FcpConnection { } /** + * Notifies listeners that a “SSKKeypair” message was received. + * + * @see FcpListener#receivedSSKKeypair(FcpConnection, SSKKeypair) + * @param sskKeypair + * The “SSKKeypair” message + */ + private void fireReceivedSSKKeypair(SSKKeypair sskKeypair) { + for (FcpListener fcpListener: fcpListeners) { + fcpListener.receivedSSKKeypair(this, sskKeypair); + } + } + + /** * Notifies all registered listeners that a message has been received. * * @see FcpListener#receivedMessage(FcpConnection, FcpMessage) @@ -243,7 +257,9 @@ public class FcpConnection { */ void handleMessage(FcpMessage fcpMessage) { String messageName = fcpMessage.getName(); - if ("NodeHello".equals(messageName)) { + if ("SSKKeypair".equals(messageName)) { + fireReceivedSSKKeypair(new SSKKeypair(fcpMessage)); + } else if ("NodeHello".equals(messageName)) { fireReceivedNodeHello(new NodeHello(fcpMessage)); } else if ("CloseConnectionDuplicateClientName".equals(messageName)) { fireReceivedCloseConnectionDuplicateClientName(new CloseConnectionDuplicateClientName(fcpMessage)); diff --git a/src/net/pterodactylus/util/fcp/FcpListener.java b/src/net/pterodactylus/util/fcp/FcpListener.java index 21caa9c..a983f88 100644 --- a/src/net/pterodactylus/util/fcp/FcpListener.java +++ b/src/net/pterodactylus/util/fcp/FcpListener.java @@ -23,6 +23,7 @@ import java.util.EventListener; import net.pterodactylus.util.fcp.message.CloseConnectionDuplicateClientName; import net.pterodactylus.util.fcp.message.NodeHello; +import net.pterodactylus.util.fcp.message.SSKKeypair; /** * Interface for objects that want to be notified on certain FCP events. @@ -54,6 +55,16 @@ public interface FcpListener extends EventListener { public void receivedCloseConnectionDuplicateClientName(FcpConnection fcpConnection, CloseConnectionDuplicateClientName closeConnectionDuplicateClientName); /** + * Notifies all listeners that a “SSKKeypair” message was received. + * + * @param fcpConnection + * The connection that received themessage + * @param sskKeypair + * The “SSKKeypair” message + */ + public void receivedSSKKeypair(FcpConnection fcpConnection, SSKKeypair sskKeypair); + + /** * Notifies listeners that a message has been received. This method is only * called if {@link FcpConnection#handleMessage(FcpMessage)} does not * recognize the message. Should that ever happen, please file a bug report! -- 2.7.4