*/
package net.pterodactylus.util.fcp;
-
/**
* Adapter for {@link FcpListener}.
*
}
/**
+ * @see net.pterodactylus.util.fcp.FcpListener#receviedPeerRemoved(net.pterodactylus.util.fcp.FcpConnection,
+ * net.pterodactylus.util.fcp.PeerRemoved)
+ */
+ public void receviedPeerRemoved(FcpConnection fcpConnection, PeerRemoved peerRemoved) {
+ /* empty. */
+ }
+
+ /**
* @see net.pterodactylus.util.fcp.FcpListener#receivedMessage(net.pterodactylus.util.fcp.FcpConnection,
* net.pterodactylus.util.fcp.FcpMessage)
*/
}
/**
+ * Notifies all listeners that a “PeerRemoved” message was received.
+ *
+ * @see FcpListener#receviedPeerRemoved(FcpConnection, PeerRemoved)
+ * @param peerRemoved
+ * The “PeerRemoved” message
+ */
+ private void fireReceivedPeerRemoved(PeerRemoved peerRemoved) {
+ for (FcpListener fcpListener: fcpListeners) {
+ fcpListener.receviedPeerRemoved(this, peerRemoved);
+ }
+ }
+
+ /**
* Notifies all registered listeners that a message has been received.
*
* @see FcpListener#receivedMessage(FcpConnection, FcpMessage)
fireReceivedEndListPeers(new EndListPeers(fcpMessage));
} else if ("SSKKeypair".equals(messageName)) {
fireReceivedSSKKeypair(new SSKKeypair(fcpMessage));
+ } else if ("PeerRemoved".equals(messageName)) {
+ fireReceivedPeerRemoved(new PeerRemoved(fcpMessage));
} else if ("NodeHello".equals(messageName)) {
fireReceivedNodeHello(new NodeHello(fcpMessage));
} else if ("CloseConnectionDuplicateClientName".equals(messageName)) {
import java.util.EventListener;
-
/**
* Interface for objects that want to be notified on certain FCP events.
*
public void receivedEndListPeerNotes(FcpConnection fcpConnection, EndListPeerNotes endListPeerNotes);
/**
+ * Notifies a listener that a “PeerRemoved” message was received.
+ *
+ * @param fcpConnection
+ * The connection that received the message
+ * @param peerRemoved
+ * The “PeerRemoved” message
+ */
+ public void receviedPeerRemoved(FcpConnection fcpConnection, PeerRemoved peerRemoved);
+
+ /**
* Notifies a listener 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!
--- /dev/null
+/**
+ * © 2008 INA Service GmbH
+ */
+package net.pterodactylus.util.fcp;
+
+/**
+ * A “PeerRemoved” message is sent by the node when a peer has been removed.
+ *
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class PeerRemoved extends BaseMessage {
+
+ /**
+ * Creates a new “PeerRemoved” message that wraps the received message.
+ *
+ * @param receivedMessage
+ * The received message
+ */
+ public PeerRemoved(FcpMessage receivedMessage) {
+ super(receivedMessage);
+ }
+
+ /**
+ * Returns the identity of the removed peer.
+ *
+ * @return The identity of the removed peer
+ */
+ public String getIdentity() {
+ return getField("Identity");
+ }
+
+ /**
+ * Returns the node identifier of the removed peer.
+ *
+ * @return The node identifier of the removed peer
+ */
+ public String getNodeIdentifier() {
+ return getField("NodeIdentifier");
+ }
+
+}
--- /dev/null
+/**
+ * © 2008 INA Service GmbH
+ */
+package net.pterodactylus.util.fcp;
+
+/**
+ * The “RemovePeer” command removes a peer.
+ *
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class RemovePeer extends FcpMessage {
+
+ /**
+ * Creates a new “RemovePeer” command that removes the given peer.
+ *
+ * @param nodeIdentifier
+ * The identifier of the node, i.e. its name, identity, or IP
+ * address and port pair
+ */
+ public RemovePeer(String nodeIdentifier) {
+ super("RemovePeer");
+ setField("NodeIdentifier", nodeIdentifier);
+ }
+
+}