WIP2 système de connection à plusieurs utilisateurs
This commit is contained in:
parent
a745f39e0c
commit
73664235ba
1 changed files with 8 additions and 0 deletions
|
@ -124,7 +124,9 @@ class ConnectionListenerThread extends Thread {
|
|||
{
|
||||
try
|
||||
{
|
||||
System.out.println("Waiting for connection request");
|
||||
requestSocket.receive(request);
|
||||
System.out.println("Received a request!");
|
||||
username = new String(request.getData(), 0, request.getLength());
|
||||
InetAddress clientAddress= request.getAddress();
|
||||
|
||||
|
@ -225,12 +227,17 @@ public class ClientWindow implements ActionListener {
|
|||
userList = (ArrayList<String>) userListStream.readObject();
|
||||
hostList = (ArrayList<String>) hostListStream.readObject();
|
||||
|
||||
System.out.println(userList.size() + "users currently connected");
|
||||
|
||||
if (userList.indexOf(username) != -1)
|
||||
connected = false;
|
||||
else
|
||||
{
|
||||
user.add_to_known_users(username, InetAddress.getLocalHost().getHostAddress());
|
||||
for(int i = 0;i < userList.size();i ++)
|
||||
{
|
||||
System.out.println(userList.get(i));
|
||||
System.out.println(hostList.get(i));
|
||||
user.add_to_known_users(userList.get(i), hostList.get(i));
|
||||
}
|
||||
connected = true;
|
||||
|
@ -238,6 +245,7 @@ public class ClientWindow implements ActionListener {
|
|||
}
|
||||
catch(SocketTimeoutException e)
|
||||
{
|
||||
user.add_to_known_users(username, InetAddress.getLocalHost().getHostAddress());
|
||||
System.out.println("Reply timed out");
|
||||
connected = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue