add ListPeerNote command and replies
[jSite2.git] / src / net / pterodactylus / util / fcp / FcpConnection.java
index 6d4ca97..a8b6024 100644 (file)
@@ -29,9 +29,11 @@ import java.util.ArrayList;
 import java.util.List;
 
 import net.pterodactylus.util.fcp.message.CloseConnectionDuplicateClientName;
+import net.pterodactylus.util.fcp.message.EndListPeerNotes;
 import net.pterodactylus.util.fcp.message.EndListPeers;
 import net.pterodactylus.util.fcp.message.NodeHello;
 import net.pterodactylus.util.fcp.message.Peer;
+import net.pterodactylus.util.fcp.message.PeerNote;
 import net.pterodactylus.util.fcp.message.SSKKeypair;
 import net.pterodactylus.util.io.Closer;
 
@@ -188,6 +190,7 @@ public class FcpConnection {
        /**
         * Notifies listeners that a “Peer” message was received.
         * 
+        * @see FcpListener#receivedPeer(FcpConnection, Peer)
         * @param peer
         *            The “Peer” message
         */
@@ -200,6 +203,7 @@ public class FcpConnection {
        /**
         * Notifies all listeners that an “EndListPeers” message was received.
         * 
+        * @see FcpListener#receivedEndListPeers(FcpConnection, EndListPeers)
         * @param endListPeers
         *            The “EndListPeers” message
         */
@@ -210,6 +214,32 @@ public class FcpConnection {
        }
 
        /**
+        * Notifies all listeners that a “PeerNote” message was received.
+        * 
+        * @see FcpListener#receviedPeerNote(FcpConnection, PeerNote)
+        * @param peerNote
+        */
+       private void fireReceivedPeerNote(PeerNote peerNote) {
+               for (FcpListener fcpListener: fcpListeners) {
+                       fcpListener.receviedPeerNote(this, peerNote);
+               }
+       }
+
+       /**
+        * Notifies all listeners that an “EndListPeerNotes” message was received.
+        * 
+        * @see FcpListener#receivedEndListPeerNotes(FcpConnection,
+        *      EndListPeerNotes)
+        * @param endListPeerNotes
+        *            The “EndListPeerNotes” message
+        */
+       private void fireReceivedEndListPeerNotes(EndListPeerNotes endListPeerNotes) {
+               for (FcpListener fcpListener: fcpListeners) {
+                       fcpListener.receivedEndListPeerNotes(this, endListPeerNotes);
+               }
+       }
+
+       /**
         * Notifies all registered listeners that a message has been received.
         * 
         * @see FcpListener#receivedMessage(FcpConnection, FcpMessage)
@@ -285,6 +315,10 @@ public class FcpConnection {
                String messageName = fcpMessage.getName();
                if ("Peer".equals(messageName)) {
                        fireReceivedPeer(new Peer(fcpMessage));
+               } else if ("PeerNote".equals(messageName)) {
+                       fireReceivedPeerNote(new PeerNote(fcpMessage));
+               } else if ("EndListPeerNotes".equals(messageName)) {
+                       fireReceivedEndListPeerNotes(new EndListPeerNotes(fcpMessage));
                } else if ("EndListPeers".equals(messageName)) {
                        fireReceivedEndListPeers(new EndListPeers(fcpMessage));
                } else if ("SSKKeypair".equals(messageName)) {