WIP3 système de connection à plusieurs utilisateurs
This commit is contained in:
parent
73664235ba
commit
17e9a0b650
1 changed files with 5 additions and 4 deletions
|
@ -139,8 +139,9 @@ class ConnectionListenerThread extends Thread {
|
||||||
response2 = bStream.toByteArray();
|
response2 = bStream.toByteArray();
|
||||||
responsePacket2 = new DatagramPacket(response2, response2.length, clientAddress, 1338);
|
responsePacket2 = new DatagramPacket(response2, response2.length, clientAddress, 1338);
|
||||||
responseSocket.send(responsePacket2);
|
responseSocket.send(responsePacket2);
|
||||||
|
|
||||||
if(!user.findUser(username))
|
if(!user.findUser(username))
|
||||||
user.add_to_known_users(username, clientAddress.toString());
|
user.add_to_known_users(username, clientAddress.getHostAddress());
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(SocketTimeoutException e)
|
catch(SocketTimeoutException e)
|
||||||
|
@ -227,7 +228,7 @@ public class ClientWindow implements ActionListener {
|
||||||
userList = (ArrayList<String>) userListStream.readObject();
|
userList = (ArrayList<String>) userListStream.readObject();
|
||||||
hostList = (ArrayList<String>) hostListStream.readObject();
|
hostList = (ArrayList<String>) hostListStream.readObject();
|
||||||
|
|
||||||
System.out.println(userList.size() + "users currently connected");
|
System.out.println(userList.size() + " users currently connected");
|
||||||
|
|
||||||
if (userList.indexOf(username) != -1)
|
if (userList.indexOf(username) != -1)
|
||||||
connected = false;
|
connected = false;
|
||||||
|
@ -236,8 +237,8 @@ public class ClientWindow implements ActionListener {
|
||||||
user.add_to_known_users(username, InetAddress.getLocalHost().getHostAddress());
|
user.add_to_known_users(username, InetAddress.getLocalHost().getHostAddress());
|
||||||
for(int i = 0;i < userList.size();i ++)
|
for(int i = 0;i < userList.size();i ++)
|
||||||
{
|
{
|
||||||
System.out.println(userList.get(i));
|
System.out.println("Name:" + userList.get(i));
|
||||||
System.out.println(hostList.get(i));
|
System.out.println("Address:" + hostList.get(i));
|
||||||
user.add_to_known_users(userList.get(i), hostList.get(i));
|
user.add_to_known_users(userList.get(i), hostList.get(i));
|
||||||
}
|
}
|
||||||
connected = true;
|
connected = true;
|
||||||
|
|
Loading…
Reference in a new issue