X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Ffcp%2Fhighlevel%2FFcpClient.java;h=5a3ec091afb6182cc71c71b9acb94a320fe97b80;hb=d649abb6cc777878323c0e21ee665e88934d3873;hp=88bc13f9ec29b58b04a96a0643966739ca695a45;hpb=534a085e40b52ab8df7d113e159d108744b8d2a1;p=jFCPlib.git
diff --git a/src/net/pterodactylus/fcp/highlevel/FcpClient.java b/src/net/pterodactylus/fcp/highlevel/FcpClient.java
index 88bc13f..5a3ec09 100644
--- a/src/net/pterodactylus/fcp/highlevel/FcpClient.java
+++ b/src/net/pterodactylus/fcp/highlevel/FcpClient.java
@@ -35,6 +35,7 @@ import net.pterodactylus.fcp.FcpAdapter;
import net.pterodactylus.fcp.FcpConnection;
import net.pterodactylus.fcp.FcpListener;
import net.pterodactylus.fcp.ListPeers;
+import net.pterodactylus.fcp.ModifyPeer;
import net.pterodactylus.fcp.NodeHello;
import net.pterodactylus.fcp.NodeRef;
import net.pterodactylus.fcp.Peer;
@@ -335,6 +336,49 @@ public class FcpClient {
}
/**
+ * Modifies the given peer.
+ *
+ * @param peer
+ * The peer to modify
+ * @param allowLocalAddresses
+ * true
to allow local address, false
+ * to not allow local address, null
to not change
+ * the setting
+ * @param disabled
+ * true
to disable the peer, false
to
+ * enable the peer, null
to not change the setting
+ * @param listenOnly
+ * true
to enable âlisten onlyâ for the peer,
+ * false
to disable it, null
to not
+ * change it
+ * @throws IOException
+ * if an I/O error occurs
+ * @throws FcpException
+ * if an FCP error occurs
+ */
+ public void modifyPeer(Peer peer, Boolean allowLocalAddresses, Boolean disabled, Boolean listenOnly) throws IOException, FcpException {
+ ExtendedFcpAdapter fcpListener = new ExtendedFcpAdapter() {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void receivedPeer(FcpConnection fcpConnection, Peer peer) {
+ completionLatch.countDown();
+ }
+ };
+ fcpConnection.addFcpListener(fcpListener);
+ try {
+ fcpConnection.sendMessage(new ModifyPeer(peer.getIdentity(), allowLocalAddresses, disabled, listenOnly));
+ } finally {
+ fcpConnection.removeFcpListener(fcpListener);
+ }
+ if (fcpListener.getFcpException() != null) {
+ throw fcpListener.getFcpException();
+ }
+ }
+
+ /**
* Implementation of an {@link FcpListener} that can store an
* {@link FcpException} and wait for the arrival of a certain command.
*