|  | @@ -41,6 +41,11 @@ public class BomberStudentClient {
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      protected TcpClient socket;
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * Si le client est conecter à un serveur en TCP
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    protected boolean connect;
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * Class de gestion des requetes serveurs
 | 
	
		
			
				|  |  |       */
 | 
	
	
		
			
				|  | @@ -114,7 +119,11 @@ public class BomberStudentClient {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //Creation socket d'envoi
 | 
	
		
			
				|  |  |          this.socket = new TcpClient(serv.get(index), this.portTcp);
 | 
	
		
			
				|  |  | -        return this.socket.connect();
 | 
	
		
			
				|  |  | +        if(this.socket.connect()){
 | 
	
		
			
				|  |  | +            this.connect = true;
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return false;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
	
		
			
				|  | @@ -168,29 +177,35 @@ public class BomberStudentClient {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * Ferme la connexion
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @return Reussite
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      public boolean close() {
 | 
	
		
			
				|  |  | -        try {
 | 
	
		
			
				|  |  | -            //Laisse le temps au serveur de voir les messages
 | 
	
		
			
				|  |  | -            Thread.sleep(5000);
 | 
	
		
			
				|  |  | -        } catch (InterruptedException ex) {
 | 
	
		
			
				|  |  | -            
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        //Avertit le serveur
 | 
	
		
			
				|  |  | -        this.send("POST", "client/end");
 | 
	
		
			
				|  |  | -        //Coupe le thread
 | 
	
		
			
				|  |  | -        this.request.interrupt();
 | 
	
		
			
				|  |  | -        //Verif que le thread est bien arréte
 | 
	
		
			
				|  |  | -        try {
 | 
	
		
			
				|  |  | -            Thread.sleep(3000);
 | 
	
		
			
				|  |  | -            if (this.request.isAlive()) {
 | 
	
		
			
				|  |  | -                System.err.println("Imposible de tuer le thread de gestion des requetes");
 | 
	
		
			
				|  |  | +        //Si connecté à un serveur
 | 
	
		
			
				|  |  | +        if (this.connect) {
 | 
	
		
			
				|  |  | +            this.connect = false;
 | 
	
		
			
				|  |  | +            try {
 | 
	
		
			
				|  |  | +                //Laisse le temps au serveur de voir les messages
 | 
	
		
			
				|  |  | +                Thread.sleep(5000);
 | 
	
		
			
				|  |  | +            } catch (InterruptedException ex) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -        } catch (InterruptedException ex) {
 | 
	
		
			
				|  |  | +            //Avertit le serveur
 | 
	
		
			
				|  |  | +            this.send("POST", "client/end");
 | 
	
		
			
				|  |  | +            //Coupe le thread
 | 
	
		
			
				|  |  | +            this.request.interrupt();
 | 
	
		
			
				|  |  | +            //Verif que le thread est bien arréte
 | 
	
		
			
				|  |  | +            try {
 | 
	
		
			
				|  |  | +                Thread.sleep(3000);
 | 
	
		
			
				|  |  | +                if (this.request.isAlive()) {
 | 
	
		
			
				|  |  | +                    System.err.println("Imposible de tuer le thread de gestion des requetes");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            } catch (InterruptedException ex) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            return this.socket.close();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        return this.socket.close();
 | 
	
		
			
				|  |  | +        return true;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  }
 |