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