X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fde%2Ftodesbaum%2Futil%2Ffreenet%2Ffcp2%2FClient.java;h=63fa4185722d792e01508525fdefe10f501cc624;hb=7dee6ec51d770004481ef6f4eab96e8f03fe0af9;hp=e904a2631b262eb2798904eb0338f2de7ece3928;hpb=6f1a8216cfba28add0ef365b46a08d16d4eb87fe;p=jSite.git
diff --git a/src/de/todesbaum/util/freenet/fcp2/Client.java b/src/de/todesbaum/util/freenet/fcp2/Client.java
index e904a26..63fa418 100644
--- a/src/de/todesbaum/util/freenet/fcp2/Client.java
+++ b/src/de/todesbaum/util/freenet/fcp2/Client.java
@@ -1,5 +1,5 @@
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
@@ -23,12 +23,14 @@ 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.
- *
+ *
* @author David Roden <droden@gmail.com>
- * @version $Id: Client.java 413 2006-03-29 12:22:31Z bombe $
+ * @version $Id$
*/
public class Client implements ConnectionListener {
@@ -49,7 +51,7 @@ public class Client implements ConnectionListener {
/**
* Creates a new client that operates on the specified connection.
- *
+ *
* @param connection
* The connection to operate on
*/
@@ -61,7 +63,7 @@ public class Client implements ConnectionListener {
/**
* Creates a new client that operates on the specified connection and
* immediately executes the specified command.
- *
+ *
* @param connection
* The connection to operate on
* @param command
@@ -78,7 +80,7 @@ public class Client implements ConnectionListener {
/**
* Returns whether this client catches all messages going over the
* connection.
- *
+ *
* @return true
if the client catches all messages,
* false
otherwise
*/
@@ -88,7 +90,7 @@ public class Client implements ConnectionListener {
/**
* Sets whether this client catches all messages going over the connection.
- *
+ *
* @param catchAll
* true
if the client should catch all messages,
* false
otherwise
@@ -101,7 +103,7 @@ 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
* @throws IOException
@@ -113,9 +115,26 @@ 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.
- *
+ *
* @param command
* The command to execute
* @param removeExistingIdentifiers
@@ -125,6 +144,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,14 +169,14 @@ public class Client implements ConnectionListener {
}
identifiers.add(command.getIdentifier());
}
- connection.execute(command);
+ connection.execute(command, progressListener);
}
/**
* Returns the next message, waiting endlessly for it, if need be. If you
* are not sure whether a message will arrive, better use
* {@link #readMessage(long)} to only wait for a specific time.
- *
+ *
* @return The next message that resulted from the execution of the last
* command
* @see #readMessage(long)
@@ -153,7 +190,7 @@ public class Client implements ConnectionListener {
* Returns the next message. If the message queue is currently empty, at
* least maxWaitTime
milliseconds will be waited for a
* message to arrive.
- *
+ *
* @param maxWaitTime
* The minimum time to wait for a message, in milliseconds
* @return The message, or null
if no message arrived in time
@@ -181,7 +218,7 @@ public class Client implements ConnectionListener {
/**
* Returns whether the client is currently disconnected.
- *
+ *
* @return true
if the client is disconnected,
* false
otherwise
*/