Browse Source

refactoring: Kommentare

remotes/origin/feature/client/make-input-field-buttons-interactive^2
Paul Kattenborn 11 months ago
parent
commit
0dd61cb78c
  1. 8
      src/main/java/ChatServer.java

8
src/main/java/ChatServer.java

@ -7,10 +7,10 @@ import java.util.concurrent.CopyOnWriteArrayList;
public class ChatServer { public class ChatServer {
private ServerSocket serverSocket; private ServerSocket serverSocket;
private List<ClientHandler> clients;
private List<ClientHandler> clients; // Liste, um alle verbundenen Clients zu verwalten
public ChatServer(int port) { public ChatServer(int port) {
clients = new CopyOnWriteArrayList<>();
clients = new CopyOnWriteArrayList<>(); // Verwende CopyOnWriteArrayList für die Thread-Sicherheit
try { try {
serverSocket = new ServerSocket(port); serverSocket = new ServerSocket(port);
@ -18,9 +18,9 @@ public class ChatServer {
while (true) { while (true) {
System.out.println("waiting for new Client..."); System.out.println("waiting for new Client...");
Socket connectionToClient = serverSocket.accept();
Socket connectionToClient = serverSocket.accept(); // Auf Verbindungen von Clients warten
ClientHandler client = new ClientHandler(this, connectionToClient); ClientHandler client = new ClientHandler(this, connectionToClient);
clients.add(client);
clients.add(client); // Neuen Client zur Liste hinzufügen
System.out.println("Accepted new Client"); System.out.println("Accepted new Client");
} }
} catch (IOException e) { } catch (IOException e) {

Loading…
Cancel
Save