Browse Source

add messagelogger

Patrick Glavin 6 years ago
parent
commit
c2fee99dac
2 changed files with 25 additions and 2 deletions
  1. 23
    0
      Client/src/main/java/MessageLogger.java
  2. 2
    2
      Client/src/main/java/SimpleShell.java

+ 23
- 0
Client/src/main/java/MessageLogger.java View File

@@ -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 View File

@@ -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.