From 37dac9ebe3384ef47140e25bd17d32c41e0d1056 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 19 Jul 2009 15:08:44 +0200 Subject: [PATCH] Add getNodeInformation() method (implements GetNode request). --- src/net/pterodactylus/fcp/highlevel/FcpClient.java | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/net/pterodactylus/fcp/highlevel/FcpClient.java b/src/net/pterodactylus/fcp/highlevel/FcpClient.java index 8a7a90d..4bbcded 100644 --- a/src/net/pterodactylus/fcp/highlevel/FcpClient.java +++ b/src/net/pterodactylus/fcp/highlevel/FcpClient.java @@ -47,11 +47,13 @@ import net.pterodactylus.fcp.FcpConnection; import net.pterodactylus.fcp.FcpListener; import net.pterodactylus.fcp.GenerateSSK; import net.pterodactylus.fcp.GetFailed; +import net.pterodactylus.fcp.GetNode; import net.pterodactylus.fcp.ListPeerNotes; import net.pterodactylus.fcp.ListPeers; import net.pterodactylus.fcp.ListPersistentRequests; import net.pterodactylus.fcp.ModifyPeer; import net.pterodactylus.fcp.ModifyPeerNote; +import net.pterodactylus.fcp.NodeData; import net.pterodactylus.fcp.NodeHello; import net.pterodactylus.fcp.NodeRef; import net.pterodactylus.fcp.Peer; @@ -886,6 +888,47 @@ public class FcpClient { } // + // NODE INFORMATION + // + + /** + * Returns information about the node. + * + * @param giveOpennetRef + * Whether to return the OpenNet reference + * @param withPrivate + * Whether to return private node data + * @param withVolatile + * Whether to return volatile node data + * @return Node information + * @throws FcpException + * if an FCP error occurs + * @throws IOException + * if an I/O error occurs + */ + public NodeData getNodeInformation(final Boolean giveOpennetRef, final Boolean withPrivate, final Boolean withVolatile) throws IOException, FcpException { + final ObjectWrapper nodeDataWrapper = new ObjectWrapper(); + new ExtendedFcpAdapter() { + + @Override + @SuppressWarnings("synthetic-access") + public void run() throws IOException { + GetNode getNodeMessage = new GetNode(giveOpennetRef, withPrivate, withVolatile); + fcpConnection.sendMessage(getNodeMessage); + } + + /** + * {@inheritDoc} + */ + @Override + public void receivedNodeData(FcpConnection fcpConnection, NodeData nodeData) { + nodeDataWrapper.set(nodeData); + } + }.execute(); + return nodeDataWrapper.get(); + } + + // // PRIVATE METHODS // -- 2.7.4