X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Ffcp%2Fquelaton%2FDefaultFcpClient.java;h=6cefb4699cea241c1c8a6f1a2e483b61e2a07edd;hb=fc1c3f3719425dfafb42fedef9ecad05783dd32c;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..6cefb46 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,6 +70,11 @@ 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); }