From a6097ca49a19f8c81e32fcb1cc94d3ba6209d631 Mon Sep 17 00:00:00 2001 From: m-gues Date: Sat, 13 Feb 2021 17:21:00 +0100 Subject: [PATCH] javadoc connexion en cours 2 --- POO/src/connexion/ControleurConnexion.java | 25 ++++++------------- POO/src/connexion/VueConnexion.java | 29 ++++++++++++++++++++-- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/POO/src/connexion/ControleurConnexion.java b/POO/src/connexion/ControleurConnexion.java index c8613db..5f3d55d 100644 --- a/POO/src/connexion/ControleurConnexion.java +++ b/POO/src/connexion/ControleurConnexion.java @@ -29,7 +29,6 @@ public class ControleurConnexion implements ActionListener{ this.username = ""; this.sqlManager = new SQLiteManager(0); this.vueStd = null; - //Pour les tests, changer pour un truc plus général quand on change CommunicationUDP int[] portServer = {2209, 2309, 2409, 2509}; try { @@ -53,8 +52,7 @@ public class ControleurConnexion implements ActionListener{ default : this.comUDP = new CommunicationUDP(2408, 2409, portServer); this.portTCP = 7040; - } -// + } } catch (IOException e) { e.printStackTrace(); @@ -82,25 +80,18 @@ public class ControleurConnexion implements ActionListener{ if (inputOK) { this.etat=Etat.ID_OK; - //Envoi broadcast du message "JeSuisActif" et, attente du retour de la liste des utilisateurs actifs + //Broadcast "JE_SUIS_CONNECTE" message and waits for the other devices' answers try { comUDP.sendMessageConnecte(); - } catch (UnknownHostException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); + } catch (IOException e2) { } - + try { Thread.sleep(2); } catch (InterruptedException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); } - //Mise en place de la demande du pseudo + //setup pseudo ask this.vue.setConnexionInfo(""); this.vue.removePasswordPanel(); @@ -117,12 +108,12 @@ public class ControleurConnexion implements ActionListener{ else { pseudo = vue.getUsernameValue(); - //Recherche dans la liste locale des utilisateurs connectes, report sur inputOK + //Search in the local list of active users id the chosen pseudo is already in use inputOK = !this.comUDP.containsUserFromPseudo(pseudo); if(pseudo.equals("")) { this.vue.setConnexionInfo("Votre pseudonyme doit contenir au moins 1 caratère"); }else if (inputOK) { - //Reglage de l'utilisateur + //setup Utilisateur "self" static attribute try { Utilisateur.setSelf(this.username, pseudo, "localhost", this.portTCP); } catch (UnknownHostException e2) { @@ -130,7 +121,7 @@ public class ControleurConnexion implements ActionListener{ e2.printStackTrace(); } - //Broadcast du pseudo + //broadcast new pseudo try { this.comUDP.sendMessageInfoPseudo(); } catch (UnknownHostException e1) { diff --git a/POO/src/connexion/VueConnexion.java b/POO/src/connexion/VueConnexion.java index 3cf3bf9..efef823 100644 --- a/POO/src/connexion/VueConnexion.java +++ b/POO/src/connexion/VueConnexion.java @@ -116,10 +116,20 @@ public class VueConnexion extends Vue { //----- GETTERS -----// + /** + * Returns the current value of the field inputUsername + * + * @return current value of the field inputUsername as String + */ protected String getUsernameValue() { return this.inputUsername.getText(); } + /** + * Returns the current value of the field inputPassword + * + * @return current value of the field inputPassword as String + */ protected char[] getPasswordValue() { return this.inputPassword.getPassword(); } @@ -127,21 +137,36 @@ public class VueConnexion extends Vue { //----- SETTERS -----// + /** + * Set a displayed message that will give the user information (for example if they entered a wrong password) + * + * @param text : message to display as String + */ protected void setConnexionInfo(String text) { this.connexionInfo.setText(text); } + /** + * Set the label for the inputUsername fiel + * + * @param text : label to display as String + */ protected void setTextUsernameField(String text) { this.labelUsername.setText(text); } + /** + * Empty the inputUsername text field + */ protected void resetUsernameField() { this.inputUsername.setText(""); } - + /** + * Empty the inputPassword text field + */ protected void resetPasswordField() { this.inputPassword.setText(""); } -} +} \ No newline at end of file