X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Futil%2Ffreenet%2Ffcp2%2FClient.java;h=ede92d13e9e890eeda4c781ab69302139f3d890a;hb=953de352675a4ad91fe307d816a4ea7780c94274;hp=93761598256424ca4f3a3dc0c9d96fe2d4b3f23a;hpb=bbfa208695e2a7f1bb555f841623945767f296e7;p=jSite.git diff --git a/src/de/todesbaum/util/freenet/fcp2/Client.java b/src/de/todesbaum/util/freenet/fcp2/Client.java index 9376159..ede92d1 100644 --- a/src/de/todesbaum/util/freenet/fcp2/Client.java +++ b/src/de/todesbaum/util/freenet/fcp2/Client.java @@ -1,6 +1,5 @@ /* - * todesbaum-lib - - * Copyright (C) 2006 David Roden + * jSite - Client.java - Copyright © 2006–2012 David Roden * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +22,8 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import de.todesbaum.util.io.StreamCopier.ProgressListener; + /** * A Client executes {@link Command}s over a {@link Connection} to a * {@link Node} and delivers resulting {@link Message}s. @@ -113,6 +114,23 @@ public class Client implements ConnectionListener { } /** + * Executes the specified command. This will also clear the queue of + * messages, discarding all messages that resulted from the previous + * command and have not yet been read. + * + * @param command + * The command to execute + * @param progressListener + * The progress listener for payload transfers + * @throws IOException + * if an I/O error occurs + * @see #execute(Command, boolean) + */ + public void execute(Command command, ProgressListener progressListener) throws IOException { + execute(command, true, progressListener); + } + + /** * Executes the specified command and optionally clears the list of * identifiers this clients listens to before starting the command. * @@ -125,6 +143,24 @@ public class Client implements ConnectionListener { * if an I/O error occurs */ public void execute(Command command, boolean removeExistingIdentifiers) throws IOException { + execute(command, removeExistingIdentifiers, null); + } + + /** + * Executes the specified command and optionally clears the list of + * identifiers this clients listens to before starting the command. + * + * @param command + * The command to execute + * @param removeExistingIdentifiers + * If true, the list of identifiers that this + * clients listens to is cleared + * @param progressListener + * The progress listener for payload transfers + * @throws IOException + * if an I/O error occurs + */ + public void execute(Command command, boolean removeExistingIdentifiers, ProgressListener progressListener) throws IOException { synchronized (messageQueue) { messageQueue.clear(); if (removeExistingIdentifiers) { @@ -132,7 +168,7 @@ public class Client implements ConnectionListener { } identifiers.add(command.getIdentifier()); } - connection.execute(command); + connection.execute(command, progressListener); } /**