-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientMain.java
More file actions
43 lines (30 loc) · 1017 Bytes
/
ClientMain.java
File metadata and controls
43 lines (30 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.util.Scanner;
public class ClientMain {
public static void main(String[] args) {
Client client = new Client();
Scanner sc = new Scanner(System.in);
while(true) {
System.out.println("\n1. Connect to Server");
System.out.println("2. Send Message");
System.out.println("3. Close Client");
int choice = sc.nextInt();
sc.nextLine();
switch(choice) {
case 1:
client.connect();
// listen to server messages
new Thread(() -> client.receive()).start();
break;
case 2:
System.out.print("Enter message: ");
String msg = sc.nextLine();
client.send(msg);
break;
case 3:
client.close();
sc.close();
return;
}
}
}
}