Skip to content

Commit 381db33

Browse files
committed
fully implemented chat room that the admin can only send the message and the members can listen to them
1 parent 2151528 commit 381db33

File tree

12 files changed

+106
-22
lines changed

12 files changed

+106
-22
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

src/AdminClient/AdminClient.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class AdminClient {
1111
public static final int BROADCAST_PORT = 3001;
1212
public static final String Section_1 = "1";
1313
public static final String Section_2 = "2";
14-
// public static boolean end = false;
14+
1515

1616
public static void main(String[] args) throws IOException {
1717
System.out.println("Welcome, Which group do you want to broadcast your\n" +
@@ -27,14 +27,19 @@ public static void main(String[] args) throws IOException {
2727
out.println(groupSectionID);
2828
String messageInfo = null;
2929
String messageContent = null;
30-
if ((messageInfo = massageReader.readLine()) != null) {
30+
while ((messageInfo = massageReader.readLine()) != null) {
3131
System.out.println(messageInfo);
3232
BufferedReader consoleReader = new BufferedReader(new InputStreamReader(System.in));
3333
messageContent = consoleReader.readLine();
34+
if (!"end".equals(messageContent)) {
35+
out.println(messageContent);
36+
37+
}else{
38+
out.println(messageContent);
39+
break;
40+
}
3441
}
35-
while (!"end".equals(messageContent)) {
36-
out.println(messageContent);
37-
}
42+
3843
scanner.close();
3944
massageReader.close();
4045
out.close();

0 commit comments

Comments
 (0)