Browse Source

Benutzername abfrage modifiziert

remotes/origin/server
Paul Kattenborn 11 months ago
parent
commit
b762e825e9
  1. 8
      src/main/java/ChatServer.java
  2. 2
      src/main/java/ClientHandler.java
  3. 6
      user.json

8
src/main/java/ChatServer.java

@ -39,10 +39,10 @@ public class ChatServer {
} }
// Methode, um eine Nachricht an alle verbundenen Clients zu senden // Methode, um eine Nachricht an alle verbundenen Clients zu senden
public void broadcastMessage(String message) { public void broadcastMessage(String message) {
System.out.println(message);
if (message != null) {
for (ClientHandler client : clients) {
client.sendMessage(message); // Nachricht an jeden Client senden
System.out.println(message);
if (message != null) {
for (ClientHandler client : clients) {
client.sendMessage(message);
} }
} }

2
src/main/java/ClientHandler.java

@ -14,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 = JOptionPane.showInputDialog("welcher Benutzername?");
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

6
user.json

@ -10,11 +10,5 @@
"userName": "asd1", "userName": "asd1",
"password": "123456", "password": "123456",
"birthday": "1" "birthday": "1"
},
{
"id": "228bf4df-c730-4cd9-9d1c-2446607066aa",
"userName": "jo",
"password": "sieben",
"birthday": "jo"
} }
] ]
Loading…
Cancel
Save