/*
- * 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
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$
*/
/**
* Creates a new client that operates on the specified connection.
- *
+ *
* @param connection
* The connection to operate on
*/
/**
* 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
/**
* Returns whether this client catches all messages going over the
* connection.
- *
+ *
* @return <code>true</code> if the client catches all messages,
* <code>false</code> otherwise
*/
/**
* Sets whether this client catches all messages going over the connection.
- *
+ *
* @param catchAll
* <code>true</code> if the client should catch all messages,
* <code>false</code> otherwise
* 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
}
/**
+ * 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
* 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 <code>true</code>, 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) {
}
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)
* Returns the next message. If the message queue is currently empty, at
* least <code>maxWaitTime</code> 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 <code>null</code> if no message arrived in time
/**
* Returns whether the client is currently disconnected.
- *
+ *
* @return <code>true</code> if the client is disconnected,
* <code>false</code> otherwise
*/