Przeglądaj źródła

add messagelogger

Patrick Glavin 6 lat temu
rodzic
commit
c2fee99dac

+ 23
- 0
Client/src/main/java/MessageLogger.java Wyświetl plik

@@ -0,0 +1,23 @@
1
+public class MessageLogger implements Runnable{
2
+    private User user;
3
+    private YouAreEll webber;
4
+
5
+    public MessageLogger(User user, YouAreEll webber) {
6
+        this.user = user;
7
+        this.webber = webber;
8
+    }
9
+
10
+    public void run() {
11
+        String results = webber.get_messages(user);
12
+        simulateLag();
13
+        SimpleShell.prettyPrintMessages(results);
14
+    }
15
+
16
+    private void simulateLag() {
17
+        try {
18
+            Thread.sleep(10000);
19
+        } catch (InterruptedException e){
20
+            e.printStackTrace();
21
+        }
22
+    }
23
+}

+ 2
- 2
Client/src/main/java/SimpleShell.java Wyświetl plik

@@ -114,8 +114,8 @@ public class SimpleShell {
114 114
 
115 115
                 // messages
116 116
                 if (list.contains("messages")) {
117
-                    String results = webber.get_messages(user);
118
-                    SimpleShell.prettyPrintMessages(results);
117
+                    Thread thread = new Thread(new MessageLogger(user, webber));
118
+                    thread.start();
119 119
                     continue;
120 120
                 }
121 121
                 // you need to add a bunch more.