TD2: code cleanup in the client part.
[TD_SR.git] / TD2 / client / Main.java
diff --git a/TD2/client/Main.java b/TD2/client/Main.java
new file mode 100644 (file)
index 0000000..cc47bb7
--- /dev/null
@@ -0,0 +1,52 @@
+import java.io.*;
+
+
+public class Main {
+
+       /**
+        * Main for testing ClientSimplifie
+        */
+       private static void main1() {
+               SocketClient client = new SocketClient();
+
+               try {
+                       client.sendMsg("Line1");
+                       String msg = client.receiveMsg();
+                       System.out.println(msg);
+               }
+               catch (Exception e) {
+                       System.err.println("Exception: " + e);
+               }
+               finally {
+                       client.closeRWIO();
+               }
+       }
+
+
+       public static void main (String[] args) {
+               SocketClient client = new SocketClient();
+
+               // try {
+                       ThreadClientSend thCS = new ThreadClientSend(client);
+                       //FIXME: Implement a loop based on user input to set dynamically the message to sent.
+                       //for (int i = 0; i < 10; i++) {
+                       //      thCS.setMsg("Line" + i);
+                       //}
+                       thCS.setMsg("Line1");
+                       Thread thS = new Thread(thCS);
+                       Thread thR = new Thread(new ThreadClientReceive(client));
+                       thS.setName("thS");
+                       thS.start();
+                       thR.setName("thR");
+                       thR.start();
+               // }
+               // catch (Exception e) {
+               //      System.err.println("Exception: " + e);
+               // }
+               // finally {
+               //      client.closeRWIO();
+               // }
+
+       }
+
+}