X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Ffcp%2Fquelaton%2FDefaultFcpClient.java;h=09b154bee7af29ed180e562be05fcebf20ccb8b0;hb=ebede056b159ea34d294f3fac0e2def790454a48;hp=0693e1cb5834c6a4cd0d7d1c44d6a1bf66366f7f;hpb=bcbda1a1adef0a7848e87601a5dbf1741a63d1cb;p=jFCPlib.git diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/DefaultFcpClient.java b/src/main/java/net/pterodactylus/fcp/quelaton/DefaultFcpClient.java index 0693e1c..09b154b 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/DefaultFcpClient.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/DefaultFcpClient.java @@ -33,11 +33,11 @@ public class DefaultFcpClient implements FcpClient { private FcpConnection connect() throws IOException { FcpConnection fcpConnection = this.fcpConnection.get(); - if (fcpConnection != null) { + if ((fcpConnection != null) && !fcpConnection.isClosed()) { return fcpConnection; } fcpConnection = createConnection(); - this.fcpConnection.compareAndSet(null, fcpConnection); + this.fcpConnection.set(fcpConnection); return fcpConnection; } @@ -50,6 +50,11 @@ public class DefaultFcpClient implements FcpClient { } @Override + public GetNodeCommand getNode() { + return new GetNodeCommandImpl(threadPool, this::connect); + } + + @Override public GenerateKeypairCommand generateKeypair() { return new GenerateKeypairCommandImpl(threadPool, this::connect); } @@ -65,9 +70,24 @@ public class DefaultFcpClient implements FcpClient { } @Override + public ListPeerCommand listPeer() { + return new ListPeerCommandImpl(threadPool, this::connect); + } + + @Override public ListPeersCommand listPeers() { return new ListPeersCommandImpl(threadPool, this::connect); } + @Override + public AddPeerCommand addPeer() { + return new AddPeerCommandImpl(threadPool, this::connect); + } + + @Override + public ListPeerNotesCommand listPeerNotes() { + return new ListPeerNotesCommandImpl(threadPool, this::connect); + } + }