ajout de popup d'erreurs lors d'une tentative de connection avec un nom invalide
This commit is contained in:
parent
88f3760164
commit
eea9f2b769
2 changed files with 9 additions and 2 deletions
|
@ -52,6 +52,13 @@ public class ClientWindow implements ActionListener {
|
|||
JOptionPane.PLAIN_MESSAGE);
|
||||
|
||||
connected = network.connect(username);
|
||||
if(!connected)
|
||||
{
|
||||
if(username.equals(""))
|
||||
JOptionPane.showMessageDialog(chatWindow, "Please enter a username", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
else if (username != null)
|
||||
JOptionPane.showMessageDialog(chatWindow, "This username is already taken", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
if(username != null)
|
||||
|
|
|
@ -267,13 +267,13 @@ public class NetworkClient {
|
|||
System.out.println(userList.get(i).getName() + " : " + userList.get(i).getAddress());
|
||||
known_users.add(userList.get(i));
|
||||
}
|
||||
known_users.add(new User(username, "25.68.185.103"));
|
||||
known_users.add(new User(username, "25.67.234.235"));
|
||||
connected = true;
|
||||
}
|
||||
}
|
||||
catch(SocketTimeoutException e)
|
||||
{
|
||||
known_users.add(new User(username, "25.68.185.103"));
|
||||
known_users.add(new User(username, "25.67.234.235"));
|
||||
System.out.println("Reply timed out");
|
||||
connected = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue