|
|
|
@ -94,7 +94,7 @@ public abstract class ClientManagement extends ServeErrors {
|
|
|
|
|
try {
|
|
|
|
|
d.sendRequest(getTrackerSocket());
|
|
|
|
|
Payload p = d.receiveResponse().getPayload();
|
|
|
|
|
assert p instanceof DiscoverResponse : "This payload must be instance of Filelist";
|
|
|
|
|
assert p instanceof DiscoverResponse : "This payload must be instance of DiscoverResponse";
|
|
|
|
|
if (!(p instanceof DiscoverResponse)) {
|
|
|
|
|
throw new InternalError();
|
|
|
|
|
} else {
|
|
|
|
@ -155,14 +155,11 @@ public abstract class ClientManagement extends ServeErrors {
|
|
|
|
|
* @throws VersionRemoteError
|
|
|
|
|
*/
|
|
|
|
|
public String[] listDirectory() throws EmptyDirectory, InternalError, UnknownHostException, IOException, TransmissionError, ProtocolError, VersionError, SizeError, InternalRemoteError, ProtocolRemoteError, VersionRemoteError {
|
|
|
|
|
if (hostList.size() == 0) {
|
|
|
|
|
return new String[0];
|
|
|
|
|
}
|
|
|
|
|
ProtocolP2PPacket<?> d = createProtocolP2PPacket(new Payload(RequestResponseCode.LIST_REQUEST));
|
|
|
|
|
try {
|
|
|
|
|
d.sendRequest(getHostItemSocket(hostList.get(0)));
|
|
|
|
|
d.sendRequest(getTrackerSocket());
|
|
|
|
|
Payload p = d.receiveResponse().getPayload();
|
|
|
|
|
closeHostItemSocket(hostList.get(0));
|
|
|
|
|
closeTrackerSocket();
|
|
|
|
|
assert p instanceof FileList : "This payload must be instance of Filelist";
|
|
|
|
|
if (!(p instanceof FileList)) {
|
|
|
|
|
throw new InternalError();
|
|
|
|
|