Commit 9de0d7f5 authored by unknown's avatar unknown
Browse files

merging

parents b602b364 26ebaaa8
......@@ -20,8 +20,7 @@ import org.json.simple.parser.ParseException;
* @author Kevin Zhong Local
*/
public class EndpointMethod {
public String inventory(String username) throws IOException, ParseException {
public static String inventory(String username) throws IOException, ParseException {
JSONObject resultJson = new JSONObject();
JSONArray inventory_list = new JSONArray();
JSONParser parser = new JSONParser();
......@@ -52,7 +51,7 @@ public class EndpointMethod {
return resultJson.toString();
}
public String mixItem(String username, String item1, String item2) {
public static String mixItem(String username, String item1, String item2) {
JSONObject resultJson = new JSONObject();
JSONParser parser = new JSONParser();
try {
......@@ -238,9 +237,12 @@ public class EndpointMethod {
return resultJson.toString();
}
public static void main(String argv[]) throws IOException, ParseException {
// EndpointMethod tes = new EndpointMethod();
// System.out.println(tes.inventory("Kevi"));
// System.out.println(tes.mixItem("Kevin", "r11", "r23"));
// }
}
}
......@@ -10,14 +10,46 @@
*/
import java.io.*;
import java.net.*;
import java.util.UUID;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
class TCPServer {
public static void join() throws IOException {
String sentence;
String modifiedSentence;
BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in));
Socket newServer = new Socket("167.205.32.46", 8000);
DataOutputStream outToServer = new DataOutputStream(newServer.getOutputStream());
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(newServer.getInputStream()));
sentence = inFromUser.readLine();
outToServer.write(sentence.getBytes());
modifiedSentence = inFromServer.readLine();
System.out.println("FROM SERVER: " + modifiedSentence);
newServer.close();
}
// public static String serverStatus(Object inObj) {
// JSONObject resultJson=new JSONObject();
// if (inObj != null) {
// JSONObject inJson = (JSONObject) inObj;
// if (inJson.containsKey("method")) {
// if (inJson.get("method").toString().equalsIgnoreCase("serverStatus")) {
// JSONArray server_list_active=new JSONArray();
// server_list_active= (JSONArray) inJson.get("server");
// System.out.println(server_list_active);
// resultJson.put("status", "ok");
// }
// }
// }
// resultJson.put("status", "error");
// return resultJson.toString();
// }
public static void main(String argv[]) throws Exception {
ConnectionHandler CH = new ConnectionHandler();
CH.start();
// ConnectionHandler CH = new ConnectionHandler();
// CH.start();
join();
}
}
......@@ -120,9 +120,9 @@ public class crudDB {
return resultJson.toString();
}
public static void main(String argv[]) throws Exception {
crudDB tes=new crudDB();
// public static void main(String argv[]) throws Exception {
// crudDB tes=new crudDB();
// System.out.println(tes.signUp("Kevin", "123"));
// System.out.println(tes.login("Kevin", "123"));
}
// }
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment