import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.Supplier;
import net.pterodactylus.fcp.EndListPeers;
import net.pterodactylus.fcp.ListPeers;
private final ListeningExecutorService threadPool;
private final ConnectionSupplier connectionSupplier;
+ private final Supplier<String> identifierGenerator;
private final AtomicBoolean includeMetadata = new AtomicBoolean(false);
private final AtomicBoolean includeVolatile = new AtomicBoolean(false);
- public ListPeersCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) {
+ public ListPeersCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier, Supplier<String> identifierGenerator) {
this.threadPool = MoreExecutors.listeningDecorator(threadPool);
this.connectionSupplier = connectionSupplier;
+ this.identifierGenerator = identifierGenerator;
}
@Override
}
private Collection<Peer> executeDialog() throws InterruptedException, ExecutionException, IOException {
- String identifier = new RandomIdentifierGenerator().generate();
- ListPeers listPeers = new ListPeers(identifier, includeMetadata.get(), includeVolatile.get());
+ ListPeers listPeers = new ListPeers(identifierGenerator.get(), includeMetadata.get(), includeVolatile.get());
try (ListPeersDialog listPeersDialog = new ListPeersDialog()) {
return listPeersDialog.send(listPeers).get();
}