diff --git a/Application/Clavardage/src/controller/Controller.java b/Application/Clavardage/src/controller/Controller.java index 01b578a..6fdf8ca 100644 --- a/Application/Clavardage/src/controller/Controller.java +++ b/Application/Clavardage/src/controller/Controller.java @@ -190,16 +190,18 @@ public class Controller { String tmpPseudo = view.PseudotextField.getText(); // Read user input - while(!(this.validatePseudo(tmpPseudo)) || tmpPseudo.equals(oldPseudo)) { + if(!(this.validatePseudo(tmpPseudo)) || tmpPseudo.equals(oldPseudo)) { view.Pseudolabel.setText("Already exists, enter another nickname. Your current username is: " + oldPseudo); // Read user input tmpPseudo = view.PseudotextField.getText(); // Read user input } + else { + this.myUser.setPseudo(tmpPseudo); + JOptionPane.showMessageDialog(null ,"Your new nickname : " + tmpPseudo + " is valid !"); + this.notify_remote_users(); - this.myUser.setPseudo(tmpPseudo); + } - JOptionPane.showMessageDialog(null ,"Your new nickname : " + tmpPseudo + " is valid !"); - this.notify_remote_users(); } /** *

@@ -380,11 +382,12 @@ public class Controller { } public void askCloseSession() { + closeSession(this.activeChat); this.activeChat = null; } public void closeSession(Chat c) { sendMessage(new Msg_Text(myUser.getAddIP(),"end"), c); // tell rm session STOP - JOptionPane.showMessageDialog(null ,"Close session with "+c.getRemoteUser().getPseudo()+" loading history"); + JOptionPane.showMessageDialog(null ,"Close session with "+c.getRemoteUser().getPseudo()); this.myUser.closeChat(c); }