|
|
@ -27,12 +27,13 @@ public class ChatServer { |
|
|
|
e.printStackTrace(); |
|
|
|
} finally { |
|
|
|
if (serverSocket != null) { |
|
|
|
try { |
|
|
|
serverSocket.close(); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
}} |
|
|
|
|
|
|
|
try { |
|
|
|
serverSocket.close(); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
@ -40,9 +41,9 @@ public class ChatServer { |
|
|
|
public void broadcastMessage(String message) { |
|
|
|
System.out.println(message); |
|
|
|
if (message != null) { |
|
|
|
for (ClientHandler client : clients) { |
|
|
|
client.sendMessage(message); |
|
|
|
} |
|
|
|
for (ClientHandler client : clients) { |
|
|
|
client.sendMessage(message); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
xxxxxxxxxx