Browse Source

remove send prettyprint error

Patrick Glavin 6 years ago
parent
commit
b7dc4e4e74
1 changed files with 13 additions and 1 deletions
  1. 13
    1
      Client/src/main/java/SimpleShell.java

+ 13
- 1
Client/src/main/java/SimpleShell.java View File

@@ -40,6 +40,18 @@ public class SimpleShell {
40 40
         }
41 41
     }
42 42
 
43
+    public static void prettyPrintMessage(String output) {
44
+        ObjectMapper mapper = new ObjectMapper();
45
+        Message message = null;
46
+        try {
47
+            message = mapper.readValue(output, Message.class);
48
+        } catch (IOException e) {
49
+            e.printStackTrace();
50
+        }
51
+        if (message.getToid().equals("")) System.out.println(message.getFromid() + ": " + message.getMessage() + "\n-----------------------------------------");
52
+        else System.out.println(message.getFromid() + " says to " + message.getToid() + ": " + message.getMessage() + "\n-----------------------------------------");
53
+    }
54
+
43 55
     public static void main(String[] args) throws java.io.IOException {
44 56
 
45 57
         YouAreEll webber = new YouAreEll();
@@ -126,7 +138,7 @@ public class SimpleShell {
126 138
                         message = new Message(user.getGithub(), list.get(1), sentence);
127 139
                     }
128 140
                     String results = webber.send_message(message);
129
-                    SimpleShell.prettyPrintMessages(results);
141
+                    SimpleShell.prettyPrintMessage(results);
130 142
                     continue;
131 143
                 }
132 144