Commit 76c0da7d authored by Jonathan Sudibya's avatar Jonathan Sudibya
Browse files

last master

parent 8092c720
package Controller; package Controller;
import Model.Client; import Model.Client;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.DataOutputStream; import java.io.DataOutputStream;
...@@ -39,7 +40,6 @@ public class ConnectionHandler implements Runnable { ...@@ -39,7 +40,6 @@ public class ConnectionHandler implements Runnable {
public ConnectionHandler(){ public ConnectionHandler(){
threadName = "Connection-Handler"; threadName = "Connection-Handler";
active = true; active = true;
globalID = 0; globalID = 0;
serverSocket = 6789; serverSocket = 6789;
...@@ -113,4 +113,4 @@ public class ConnectionHandler implements Runnable { ...@@ -113,4 +113,4 @@ public class ConnectionHandler implements Runnable {
} }
return ret; return ret;
} }
} }
\ No newline at end of file
...@@ -56,7 +56,7 @@ public class Client implements Runnable { ...@@ -56,7 +56,7 @@ public class Client implements Runnable {
char c = (char)buf; //converting to char char c = (char)buf; //converting to char
clientSentence += Character.toString(c); //added to the sentence and convert char to String. clientSentence += Character.toString(c); //added to the sentence and convert char to String.
} }
System.out.println("Received From "+connectionSocket.getInetAddress().getHostAddress()+ ": " + clientSentence); System.out.print(threadName + " : Received From "+connectionSocket.getInetAddress().getHostAddress()+ ": " + clientSentence);
if (!clientSentence.equals("")){ if (!clientSentence.equals("")){
outToClient = new DataOutputStream(connectionSocket.getOutputStream()); outToClient = new DataOutputStream(connectionSocket.getOutputStream());
Object obj = parser.parse(clientSentence); Object obj = parser.parse(clientSentence);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
*/ */
package Model; package Model;
import java.util.Vector; import Method.EndpointMethod;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
/** /**
...@@ -13,18 +13,18 @@ import org.json.simple.JSONObject; ...@@ -13,18 +13,18 @@ import org.json.simple.JSONObject;
* @author Jonathan * @author Jonathan
*/ */
public final class MessageProcessor { public final class MessageProcessor {
private EndpointMethod EM;
public static JSONObject getReply(JSONObject data) private MessageProcessor()
{ {
JSONObject ret = new JSONObject(); EM = new EndpointMethod();
return ret;
} }
private JSONObject statusOK() public static JSONObject getReply(JSONObject data)
{ {
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
ret.put("status", "ok");
return ret; return ret;
} }
} }
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
* @author Jonathan * @author Jonathan
*/ */
import Controller.ConnectionHandler; import Controller.ConnectionHandler;
import Controller.DBHandler;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
import java.util.Vector; import java.util.Vector;
...@@ -21,24 +22,8 @@ import org.json.simple.parser.ParseException; ...@@ -21,24 +22,8 @@ import org.json.simple.parser.ParseException;
class TCPServer { class TCPServer {
public ServerSocket welcomeSocket;
public boolean active;
public int globalID;
public Socket conSocket;
public String trackerSentence;
public TCPServer() {
active = true;
globalID = 0;
try {
welcomeSocket = new ServerSocket(2000);
// welcomeSocket.setSoTimeout(100000);
} catch (IOException ex) {
Logger.getLogger(TCPServer.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static void main(String argv[]) throws Exception { public static void main(String argv[]) throws Exception {
DBHandler.initialize();
ConnectionHandler CH = new ConnectionHandler(); ConnectionHandler CH = new ConnectionHandler();
CH.start(); CH.start();
} }
......
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