javadoc connexion en cours 2

This commit is contained in:
m-gues 2021-02-13 17:21:00 +01:00
parent fca17bbe08
commit a6097ca49a
2 changed files with 35 additions and 19 deletions

View file

@ -29,7 +29,6 @@ public class ControleurConnexion implements ActionListener{
this.username = ""; this.username = "";
this.sqlManager = new SQLiteManager(0); this.sqlManager = new SQLiteManager(0);
this.vueStd = null; this.vueStd = null;
//Pour les tests, changer pour un truc plus général quand on change CommunicationUDP
int[] portServer = {2209, 2309, 2409, 2509}; int[] portServer = {2209, 2309, 2409, 2509};
try { try {
@ -54,7 +53,6 @@ public class ControleurConnexion implements ActionListener{
this.comUDP = new CommunicationUDP(2408, 2409, portServer); this.comUDP = new CommunicationUDP(2408, 2409, portServer);
this.portTCP = 7040; this.portTCP = 7040;
} }
//
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
@ -82,25 +80,18 @@ public class ControleurConnexion implements ActionListener{
if (inputOK) { if (inputOK) {
this.etat=Etat.ID_OK; 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 { try {
comUDP.sendMessageConnecte(); comUDP.sendMessageConnecte();
} catch (UnknownHostException e1) { } catch (IOException e2) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} }
try { try {
Thread.sleep(2); Thread.sleep(2);
} catch (InterruptedException e1) { } 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.setConnexionInfo("");
this.vue.removePasswordPanel(); this.vue.removePasswordPanel();
@ -117,12 +108,12 @@ public class ControleurConnexion implements ActionListener{
else { else {
pseudo = vue.getUsernameValue(); 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); inputOK = !this.comUDP.containsUserFromPseudo(pseudo);
if(pseudo.equals("")) { if(pseudo.equals("")) {
this.vue.setConnexionInfo("Votre pseudonyme doit contenir au moins 1 caratère"); this.vue.setConnexionInfo("Votre pseudonyme doit contenir au moins 1 caratère");
}else if (inputOK) { }else if (inputOK) {
//Reglage de l'utilisateur //setup Utilisateur "self" static attribute
try { try {
Utilisateur.setSelf(this.username, pseudo, "localhost", this.portTCP); Utilisateur.setSelf(this.username, pseudo, "localhost", this.portTCP);
} catch (UnknownHostException e2) { } catch (UnknownHostException e2) {
@ -130,7 +121,7 @@ public class ControleurConnexion implements ActionListener{
e2.printStackTrace(); e2.printStackTrace();
} }
//Broadcast du pseudo //broadcast new pseudo
try { try {
this.comUDP.sendMessageInfoPseudo(); this.comUDP.sendMessageInfoPseudo();
} catch (UnknownHostException e1) { } catch (UnknownHostException e1) {

View file

@ -116,10 +116,20 @@ public class VueConnexion extends Vue {
//----- GETTERS -----// //----- GETTERS -----//
/**
* Returns the current value of the field inputUsername
*
* @return current value of the field inputUsername as String
*/
protected String getUsernameValue() { protected String getUsernameValue() {
return this.inputUsername.getText(); return this.inputUsername.getText();
} }
/**
* Returns the current value of the field inputPassword
*
* @return current value of the field inputPassword as String
*/
protected char[] getPasswordValue() { protected char[] getPasswordValue() {
return this.inputPassword.getPassword(); return this.inputPassword.getPassword();
} }
@ -127,19 +137,34 @@ public class VueConnexion extends Vue {
//----- SETTERS -----// //----- 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) { protected void setConnexionInfo(String text) {
this.connexionInfo.setText(text); this.connexionInfo.setText(text);
} }
/**
* Set the label for the inputUsername fiel
*
* @param text : label to display as String
*/
protected void setTextUsernameField(String text) { protected void setTextUsernameField(String text) {
this.labelUsername.setText(text); this.labelUsername.setText(text);
} }
/**
* Empty the inputUsername text field
*/
protected void resetUsernameField() { protected void resetUsernameField() {
this.inputUsername.setText(""); this.inputUsername.setText("");
} }
/**
* Empty the inputPassword text field
*/
protected void resetPasswordField() { protected void resetPasswordField() {
this.inputPassword.setText(""); this.inputPassword.setText("");
} }