|
|
@ -11,17 +11,17 @@ public class ChatServer { |
|
|
|
|
|
|
|
public ChatServer(int port) { |
|
|
|
clients = new CopyOnWriteArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
serverSocket = new ServerSocket(port); |
|
|
|
System.out.println("Started ChatServer on port " + port); |
|
|
|
|
|
|
|
while(true) { |
|
|
|
|
|
|
|
while (true) { |
|
|
|
System.out.println("waiting for new Client..."); |
|
|
|
Socket connectionToClient = serverSocket.accept(); |
|
|
|
ClientHandler client = new ClientHandler(this, connectionToClient); |
|
|
|
clients.add(client); |
|
|
|
System.out.println("Accepted new Client"); |
|
|
|
Socket connectionToClient = serverSocket.accept(); |
|
|
|
ClientHandler client = new ClientHandler(this, connectionToClient); |
|
|
|
clients.add(client); |
|
|
|
System.out.println("Accepted new Client"); |
|
|
|
} |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|