X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Ffcp%2Fquelaton%2FListPeersCommandImpl.java;h=921c0faf9dcffeeaa594b596082e9ec6a00b2fd7;hb=54b77863a4a3d63a0298157a87afb09007b03fc4;hp=c084cb59cab2623290d4570c3dcd95649114a842;hpb=bbe77c263f9f37b2407a6b5ce2f5e68e11bd9e7c;p=jFCPlib.git
diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/ListPeersCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/ListPeersCommandImpl.java
index c084cb5..921c0fa 100644
--- a/src/main/java/net/pterodactylus/fcp/quelaton/ListPeersCommandImpl.java
+++ b/src/main/java/net/pterodactylus/fcp/quelaton/ListPeersCommandImpl.java
@@ -3,8 +3,8 @@ package net.pterodactylus.fcp.quelaton;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import net.pterodactylus.fcp.EndListPeers;
@@ -16,7 +16,7 @@ import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
/**
- * Default {@link ListPeersCommand} implementation based on {@link FcpReplySequence}.
+ * Default {@link ListPeersCommand} implementation based on {@link FcpDialog}.
*
* @author David âBombeâ Roden
*/
@@ -46,17 +46,23 @@ public class ListPeersCommandImpl implements ListPeersCommand {
@Override
public ListenableFuture> execute() {
+ return threadPool.submit(this::executeSequence);
+ }
+
+ private Collection executeSequence() throws InterruptedException, ExecutionException, IOException {
String identifier = new RandomIdentifierGenerator().generate();
ListPeers listPeers = new ListPeers(identifier, includeMetadata.get(), includeVolatile.get());
- return threadPool.submit(() -> new ListPeersReplySequence().send(listPeers).get());
+ try (ListPeersDialog listPeersDialog = new ListPeersDialog()) {
+ return listPeersDialog.send(listPeers).get();
+ }
}
- private class ListPeersReplySequence extends FcpReplySequence> {
+ private class ListPeersDialog extends FcpDialog> {
private final Collection peers = new HashSet<>();
private final AtomicBoolean finished = new AtomicBoolean(false);
- public ListPeersReplySequence() throws IOException {
+ public ListPeersDialog() throws IOException {
super(threadPool, connectionSupplier.get());
}