option 0 now can close the program
flavien's git/Projet_JAVA_P2P_STRI2A/pipeline/pr-etape5 This commit looks good Details

pull/88/head
Flavien Haas 5 years ago
parent f531547f2d
commit 2f924af9df

@ -3,19 +3,12 @@ package clientP2P;
import java.util.Arrays;
import java.util.Scanner;
import java.util.List;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.net.UnknownHostException;
import protocolP2P.RequestResponseCode;
import protocolP2P.FileList;
import protocolP2P.ProtocolP2PPacket;
import protocolP2P.DiscoverRequest;
import protocolP2P.DiscoverResponse;
import protocolP2P.Payload;
import protocolP2P.HashAlgorithm;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import localException.ProtocolError;
import localException.InternalError;
import localException.ProtocolError;
@ -23,6 +16,13 @@ import localException.SizeError;
import localException.TransmissionError;
import localException.VersionError;
import localException.SocketClosed;
import protocolP2P.RequestResponseCode;
import protocolP2P.FileList;
import protocolP2P.ProtocolP2PPacket;
import protocolP2P.DiscoverRequest;
import protocolP2P.DiscoverResponse;
import protocolP2P.Payload;
import protocolP2P.HashAlgorithm;
import remoteException.EmptyFile;
import remoteException.EmptyDirectory;
import remoteException.InternalRemoteError;
@ -30,6 +30,7 @@ import remoteException.NotFound;
import remoteException.ProtocolRemoteError;
import remoteException.VersionRemoteError;
import remoteException.NotATracker;
import remoteException.UnknownHost;
import tools.ServeErrors;
import tools.HostItem;
import tools.Logger;
@ -228,6 +229,8 @@ public abstract class ClientManagement extends ServeErrors implements Runnable {
/** Implementation of Runnable
*/
public void run() {
boolean isrunning = true;
while (isrunning){
try {
int i = 1;
String[] list = listDirectory();
@ -240,7 +243,7 @@ public abstract class ClientManagement extends ServeErrors implements Runnable {
System.out.println("Type the number associated with the file to download:");
String f = scanner.nextLine();
if(f.equals("0")){
System.out.println("on ferme tout");
isrunning = false;
}
else{
int j = Integer.parseInt(f);
@ -283,5 +286,5 @@ public abstract class ClientManagement extends ServeErrors implements Runnable {
writeLog("File is empty", LogLevel.Error);
}
}
}
}

Loading…
Cancel
Save