This commit is contained in:
Louis Farina 2021-01-11 18:26:06 +01:00
parent e78d5e444c
commit acecf4de31

View file

@ -174,11 +174,13 @@ class ConnectionListenerThread extends Thread {
{
response += u.getName() + " ";
}
response = response.trim();
response += ";";
for(Socket s:dest_sockets)
{
response += s.getInetAddress().getHostAddress() + " ";
}
response = response.trim();
System.out.println("Response :" + response);
responseBytes = response.getBytes();
responsePacket = new DatagramPacket(responseBytes, responseBytes.length, clientAddress, 1337);
@ -300,7 +302,8 @@ public class NetworkClient {
}
for(String a:addressList)
{
dest_sockets.add(new Socket(a, 1237+(known_users.size())));
System.out.println("Connecting to " + a + " on port " + (1237+usernameList.length));
dest_sockets.add(new Socket(a, 1237+usernameList.length));
}
Collections.sort(known_users);
connected = true;
@ -318,7 +321,7 @@ public class NetworkClient {
}
catch (SocketException e2)
{
System.out.println(e2.getMessage());
e2.printStackTrace();
}
catch (Exception e3)
{
@ -337,7 +340,10 @@ public class NetworkClient {
{
dest_sockets.add(new Socket("25.67.234.235", 1237+(known_users.size())));
}
catch(IOException e){}
catch(IOException e)
{
e.printStackTrace();
}
user.setName(username);
known_users.add(new User(username));