|
@ -8,11 +8,13 @@ public class ClientHandler implements Runnable { |
|
|
private BufferedReader fromClientReader; |
|
|
private BufferedReader fromClientReader; |
|
|
private PrintWriter toClientWriter; |
|
|
private PrintWriter toClientWriter; |
|
|
|
|
|
|
|
|
|
|
|
// Constructor for ClientHandler |
|
|
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(); |
|
|
|
|
|
new Thread(this).start();} |
|
|
|
|
|
|
|
|
name = connectionToClient.getInetAddress().getHostAddress(); // Use the client's IP address as their name for simplicity |
|
|
|
|
|
|
|
|
|
|
|
new Thread(this).start();} // Start a new thread for this client handler |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void run() { |
|
|
public void run() { |
|
|