WIP7 système de connection à plusieurs utilisateurs
This commit is contained in:
parent
fdc002ff80
commit
b518621a88
1 changed files with 17 additions and 2 deletions
|
@ -165,6 +165,19 @@ class ConnectionListenerThread extends Thread {
|
|||
|
||||
|
||||
public class ClientWindow implements ActionListener {
|
||||
String getLocalIP() {
|
||||
String ip = "";
|
||||
try(final DatagramSocket socket = new DatagramSocket()){
|
||||
socket.connect(InetAddress.getByName("8.8.8.8"), 10002);
|
||||
ip = socket.getLocalAddress().getHostAddress();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
System.out.println("niiiiiiiikkk");
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
JFrame chatWindow;
|
||||
|
||||
JPanel chatPanel;
|
||||
|
@ -179,6 +192,7 @@ public class ClientWindow implements ActionListener {
|
|||
|
||||
ClientWindow()
|
||||
{
|
||||
|
||||
String username = "";
|
||||
Boolean connected = false;
|
||||
DatagramSocket connectionSocket;
|
||||
|
@ -252,7 +266,8 @@ public class ClientWindow implements ActionListener {
|
|||
}
|
||||
catch(SocketTimeoutException e)
|
||||
{
|
||||
user.add_to_known_users(username, connectionSocket.getLocalAddress().getHostAddress());
|
||||
user.add_to_known_users(username, getLocalIP());
|
||||
System.out.println(getLocalIP());
|
||||
System.out.println("Reply timed out");
|
||||
connected = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue