Theau Giraud 3 years ago
parent
commit
a168df58fb
1 changed files with 8 additions and 5 deletions
  1. 8
    5
      Application/Clavardage/src/controller/Controller.java

+ 8
- 5
Application/Clavardage/src/controller/Controller.java View File

@@ -190,16 +190,18 @@ public class Controller {
190 190
 
191 191
 	    String tmpPseudo = view.PseudotextField.getText();  // Read user input
192 192
 
193
-	    while(!(this.validatePseudo(tmpPseudo)) || tmpPseudo.equals(oldPseudo)) {
193
+	    if(!(this.validatePseudo(tmpPseudo)) || tmpPseudo.equals(oldPseudo)) {
194 194
 	        view.Pseudolabel.setText("Already exists, enter another nickname. Your current username is: " + oldPseudo);  // Read user input
195 195
 	        tmpPseudo = view.PseudotextField.getText();  // Read user input
196 196
 	    }
197
+	    else {
198
+		    this.myUser.setPseudo(tmpPseudo);
199
+		    JOptionPane.showMessageDialog(null ,"Your new nickname : " + tmpPseudo + " is valid !");
200
+		    this.notify_remote_users();
197 201
 
198
-	    this.myUser.setPseudo(tmpPseudo);
202
+	    }
199 203
 
200
-	    JOptionPane.showMessageDialog(null ,"Your new nickname : " + tmpPseudo + " is valid !");
201 204
 
202
-	    this.notify_remote_users();
203 205
 	}
204 206
 	/**
205 207
 	 * <p>
@@ -380,11 +382,12 @@ public class Controller {
380 382
 	}
381 383
 	
382 384
 	public void askCloseSession() {
385
+		closeSession(this.activeChat);
383 386
 		this.activeChat = null;
384 387
 	}
385 388
 	public void closeSession(Chat c) {
386 389
 		sendMessage(new Msg_Text(myUser.getAddIP(),"end"), c); // tell rm session STOP
387
-		JOptionPane.showMessageDialog(null ,"Close session with "+c.getRemoteUser().getPseudo()+" loading history"); 
390
+		JOptionPane.showMessageDialog(null ,"Close session with "+c.getRemoteUser().getPseudo()); 
388 391
 		this.myUser.closeChat(c);
389 392
 	}
390 393
 	

Loading…
Cancel
Save