|
@ -1,6 +1,8 @@ |
|
|
import java.io.*; |
|
|
import java.io.*; |
|
|
import java.net.Socket; |
|
|
import java.net.Socket; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.JOptionPane; |
|
|
|
|
|
|
|
|
public class ClientHandler implements Runnable { |
|
|
public class ClientHandler implements Runnable { |
|
|
private ChatServer chatServer; |
|
|
private ChatServer chatServer; |
|
|
private Socket connectionToClient; |
|
|
private Socket connectionToClient; |
|
@ -12,7 +14,7 @@ public class ClientHandler implements Runnable { |
|
|
public ClientHandler(ChatServer chatServer, Socket connectionToClient) { |
|
|
public ClientHandler(ChatServer chatServer, Socket connectionToClient) { |
|
|
this.chatServer = chatServer; |
|
|
this.chatServer = chatServer; |
|
|
this.connectionToClient = connectionToClient; |
|
|
this.connectionToClient = connectionToClient; |
|
|
name = connectionToClient.getInetAddress().getHostAddress(); // Use the client's IP address as their name for simplicity |
|
|
|
|
|
|
|
|
name = JOptionPane.showInputDialog("Benutzername für neuen Client vergeben"); |
|
|
|
|
|
|
|
|
new Thread(this).start();} // Start a new thread for this client handler |
|
|
new Thread(this).start();} // Start a new thread for this client handler |
|
|
|
|
|
|
|
|