X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Futil%2Ffcp%2FFcpConnection.java;h=6cd71b4d0f20d2036e2098e7ed2099d595f0ce59;hb=90ef444ae9f502750c837076f1588483619a4212;hp=6d4ca9745f1ad595ba8112e3cabaf2c77b478c5f;hpb=9dbb34874ce7cd4fa4703f6bde00302bef2fb295;p=jSite2.git diff --git a/src/net/pterodactylus/util/fcp/FcpConnection.java b/src/net/pterodactylus/util/fcp/FcpConnection.java index 6d4ca97..6cd71b4 100644 --- a/src/net/pterodactylus/util/fcp/FcpConnection.java +++ b/src/net/pterodactylus/util/fcp/FcpConnection.java @@ -28,11 +28,6 @@ import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; -import net.pterodactylus.util.fcp.message.CloseConnectionDuplicateClientName; -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.SSKKeypair; import net.pterodactylus.util.io.Closer; /** @@ -188,6 +183,7 @@ public class FcpConnection { /** * Notifies listeners that a “Peer” message was received. * + * @see FcpListener#receivedPeer(FcpConnection, Peer) * @param peer * The “Peer” message */ @@ -200,6 +196,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 +207,70 @@ public class FcpConnection { } /** + * Notifies all listeners that a “PeerNote” message was received. + * + * @see FcpListener#receivedPeerNote(FcpConnection, PeerNote) + * @param peerNote + */ + private void fireReceivedPeerNote(PeerNote peerNote) { + for (FcpListener fcpListener: fcpListeners) { + fcpListener.receivedPeerNote(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 listeners that a “PeerRemoved” message was received. + * + * @see FcpListener#receivedPeerRemoved(FcpConnection, PeerRemoved) + * @param peerRemoved + * The “PeerRemoved” message + */ + private void fireReceivedPeerRemoved(PeerRemoved peerRemoved) { + for (FcpListener fcpListener: fcpListeners) { + fcpListener.receivedPeerRemoved(this, peerRemoved); + } + } + + /** + * Notifies all listeners that a “NodeData” message was received. + * + * @see FcpListener#receivedNodeData(FcpConnection, NodeData) + * @param nodeData + * The “NodeData” message + */ + private void fireReceivedNodeData(NodeData nodeData) { + for (FcpListener fcpListener: fcpListeners) { + fcpListener.receivedNodeData(this, nodeData); + } + } + + /** + * Notifies all listeners that a “TestDDAReply” message was received. + * + * @param testDDAReply + * The “TestDDAReply” message + */ + private void fireReceivedTestDDAReply(TestDDAReply testDDAReply) { + for (FcpListener fcpListener: fcpListeners) { + fcpListener.receivedTestDDAReply(this, testDDAReply); + } + } + + /** * Notifies all registered listeners that a message has been received. * * @see FcpListener#receivedMessage(FcpConnection, FcpMessage) @@ -285,10 +346,20 @@ 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)) { fireReceivedSSKKeypair(new SSKKeypair(fcpMessage)); + } else if ("PeerRemoved".equals(messageName)) { + fireReceivedPeerRemoved(new PeerRemoved(fcpMessage)); + } else if ("NodeData".equals(messageName)) { + fireReceivedNodeData(new NodeData(fcpMessage)); + } else if ("TestDDAReply".equals(messageName)) { + fireReceivedTestDDAReply(new TestDDAReply(fcpMessage)); } else if ("NodeHello".equals(messageName)) { fireReceivedNodeHello(new NodeHello(fcpMessage)); } else if ("CloseConnectionDuplicateClientName".equals(messageName)) {