Lawrence Wu 6 лет назад
Родитель
Сommit
3170f7e5e5
1 измененных файлов: 38 добавлений и 1 удалений
  1. 38
    1
      Client/src/main/java/SimpleShell.java

+ 38
- 1
Client/src/main/java/SimpleShell.java Просмотреть файл

@@ -29,7 +29,7 @@ public class SimpleShell {
29 29
         //we break out with <ctrl c>
30 30
         while (true) {
31 31
             //read what the user enters
32
-            System.out.println("cmd? ");
32
+            System.out.println("cmd?");
33 33
             commandLine = console.readLine();
34 34
 
35 35
             //input parsed into array of strings(command and arguments)
@@ -75,6 +75,43 @@ public class SimpleShell {
75 75
                     SimpleShell.prettyPrint(results);
76 76
                     continue;
77 77
                 }
78
+                if (list.get(0).equals("send")){
79
+                    if (list.get(1).equals("to")){
80
+                        ObjectMapper mapper = new ObjectMapper();
81
+                        String friend = list.get(2);
82
+                        String message = "";
83
+                        for (int i = 3; i < list.size(); i++){
84
+                            message += list.get(i) + " ";
85
+                        }
86
+                        Message sendMessage = new Message("wulawrence", friend, message);
87
+                        String messageload = mapper.writeValueAsString(sendMessage);
88
+                        String results = webber.postMessage(messageload);
89
+                        SimpleShell.prettyPrint(results);
90
+                    }
91
+                    else {
92
+                        ObjectMapper mapper = new ObjectMapper();
93
+                        String message = "";
94
+                        for (int i = 1; i < list.size(); i++) {
95
+                            message += list.get(i) + " ";
96
+                        }
97
+                        Message messages = new Message("wulawrence", "", message);
98
+                        String messageload = mapper.writeValueAsString(messages);
99
+                        String results = webber.postMessage(messageload);
100
+                        SimpleShell.prettyPrint(results);
101
+                    }
102
+                }
103
+//                if (list.get(1).equals("to")){
104
+//                    ObjectMapper mapper = new ObjectMapper();
105
+//                    String friend = list.get(2);
106
+//                    String message = "";
107
+//                    for (int i = 3; i < list.size(); i++){
108
+//                        message += list.get(i) + " ";
109
+//                    }
110
+//                    Message sendMessage = new Message("wulawrence", friend, message);
111
+//                    String messageload = mapper.writeValueAsString(sendMessage);
112
+//                    String results = webber.postMessage(messageload);
113
+//                    SimpleShell.prettyPrint(results);
114
+//                }
78 115
                 // you need to add a bunch more.
79 116
 
80 117
                 //!! command returns the last command in history