added SSKKeypair message
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 9 Apr 2008 10:01:28 +0000 (10:01 +0000)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 9 Apr 2008 10:01:28 +0000 (10:01 +0000)
git-svn-id: http://trooper/svn/projects/jSite/trunk@657 c3eda9e8-030b-0410-8277-bc7414b0a119

src/net/pterodactylus/util/fcp/FcpAdapter.java
src/net/pterodactylus/util/fcp/FcpConnection.java
src/net/pterodactylus/util/fcp/FcpListener.java

index 9a70d0f..65ab77b 100644 (file)
@@ -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)
         */
index 4582eca..846e135 100644 (file)
@@ -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));
index 21caa9c..a983f88 100644 (file)
@@ -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!