TD2: Make the client send and receive object message.
[TD_SR.git] / TD2 / client / ThreadClientoReceive.java
diff --git a/TD2/client/ThreadClientoReceive.java b/TD2/client/ThreadClientoReceive.java
new file mode 100644 (file)
index 0000000..cfad0c9
--- /dev/null
@@ -0,0 +1,31 @@
+import java.io.*;
+
+public class ThreadClientoReceive implements Runnable {
+    private SocketClient client;
+
+    ThreadClientoReceive(SocketClient c) {
+        client = c;
+    }
+
+    public void run() {
+        try {
+            boolean end = false;
+            //FIXME: not exiting properly randomly from that loop!
+            while (!end) {
+                Message roMsg = client.receiveoMsg();
+                if (roMsg.getTexte().equals(".")) {
+                                       end = true;
+                }
+                System.out.println(Thread.currentThread().getName() + " a recu " + roMsg);
+            }
+        }
+        catch (IOException e) {
+            System.err.println("IOException: " + e);
+            e.printStackTrace();
+        }
+        catch (ClassNotFoundException e) {
+            System.err.println("ClassNotFoundException: " + e);
+            e.printStackTrace();
+        }
+    }
+}