From 6c037b67d79647779c2fe1c48e759546b46833f9 Mon Sep 17 00:00:00 2001 From: Valentin Spiroski Date: Sun, 4 Feb 2024 22:58:21 +0100 Subject: [PATCH] ClientHandler Konstruktor --- .gitignore | 1 + src/main/java/ClientHandler.java | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b83d222..beb9ac5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target/ +/src/main/java/ChatServer \ No newline at end of file diff --git a/src/main/java/ClientHandler.java b/src/main/java/ClientHandler.java index f3f9b3c..200dccf 100644 --- a/src/main/java/ClientHandler.java +++ b/src/main/java/ClientHandler.java @@ -4,14 +4,27 @@ import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.ServerSocket; +import java.net.Socket; + public class ClientHandler implements Runnable { - private Server server; - private ServerSocket connectionToClient; + private ChatServer chatServer; + private Socket connectionToClient; private String name; private BufferedReader fromClientReader; private PrintWriter toClientWriter; + + public ClientHandler(ChatServer chatServer, Socket connectionToClient) { + this.chatServer = chatServer; + this.connectionToClient = connectionToClient; + name = connectionToClient.getInetAddress().getHostAddress(); + new Thread(this).start(); + } + + + + @Override public void run() { // TODO Auto-generated method stub