TD2: Add response about serialization.
[TD_SR.git] / TD2 / client / Main.java
CommitLineData
18eb400b
JB
1import java.io.*;
2
3
4public class Main {
5
58312685 6 /**
b9a33c97 7 * main for testing ClientSimplifie
58312685 8 */
2c648f75 9 private static void main1() {
e018d1ec
JB
10 ClientSimplifie client = null;
11 BufferedReader userInput = null;
2c648f75
JB
12
13 try {
e018d1ec
JB
14 client = new ClientSimplifie();
15 userInput = new BufferedReader(new InputStreamReader(System.in));
16 boolean end = false;
17 while (!end) {
18 String line = userInput.readLine();
19 if (line.equals("."))
20 end = true;
21 client.sendMsg(line);
22 String rline = client.receiveMsg();
23 System.out.println(rline);
24 }
2c648f75 25 }
e018d1ec
JB
26 catch (IOException e) {
27 System.err.println("IOException: " + e);
2c648f75
JB
28 }
29 finally {
30 client.closeRWIO();
e018d1ec
JB
31 if (userInput != null) {
32 try {
33 userInput.close();
34 }
35 catch (IOException e) {
36 System.err.println("IOException: " + e);
37 }
38 }
2c648f75
JB
39 }
40 }
18eb400b 41
c4aaaeca
JB
42 /**
43 * main for text based message broadcasting
44 */
45 public static void main2() {
e018d1ec
JB
46 SocketClient client = null;
47 Thread thS = null;
48 Thread thR = null;
18eb400b 49
e018d1ec
JB
50 try {
51 client = new SocketClient();
52 thS = new Thread(new ThreadClientSend(client));
53 thR = new Thread(new ThreadClientReceive(client));
2c648f75
JB
54 thS.setName("thS");
55 thS.start();
56 thR.setName("thR");
57 thR.start();
e018d1ec
JB
58 }
59 catch (Exception e) {
60 System.err.println("Exception: " + e);
61 }
62 finally {
63 try {
64 thS.join();
65 thR.join();
66 }
67 catch (InterruptedException e) {
68 System.err.println("InterruptedException: " + e);
69 e.printStackTrace();
70 }
71 client.closeRWIO();
72 }
18eb400b
JB
73 }
74
c4aaaeca
JB
75 public static void main(String[] args) {
76 SocketClient client = null;
77 Thread thS = null;
78 Thread thR = null;
79
80 try {
1a8b0826 81 client = new SocketClient(true);
c4aaaeca
JB
82 thS = new Thread(new ThreadClientoSend(client));
83 thR = new Thread(new ThreadClientoReceive(client));
84 thS.setName("thoS");
85 thS.start();
86 thR.setName("thoR");
87 thR.start();
88 }
89 catch (Exception e) {
90 System.err.println("Exception: " + e);
91 }
92 finally {
93 try {
94 thS.join();
95 thR.join();
96 }
97 catch (InterruptedException e) {
98 System.err.println("InterruptedException: " + e);
99 e.printStackTrace();
100 }
101 client.closeRWIO();
102 }
103 }
104
18eb400b 105}