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

last master

parent 8092c720
package Controller;
import Model.Client;
import java.io.BufferedReader;
import java.io.DataOutputStream;
......@@ -39,7 +40,6 @@ public class ConnectionHandler implements Runnable {
public ConnectionHandler(){
threadName = "Connection-Handler";
active = true;
globalID = 0;
serverSocket = 6789;
......
......@@ -56,7 +56,7 @@ public class Client implements Runnable {
char c = (char)buf; //converting to char
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("")){
outToClient = new DataOutputStream(connectionSocket.getOutputStream());
Object obj = parser.parse(clientSentence);
......
......@@ -5,7 +5,7 @@
*/
package Model;
import java.util.Vector;
import Method.EndpointMethod;
import org.json.simple.JSONObject;
/**
......@@ -13,18 +13,18 @@ import org.json.simple.JSONObject;
* @author Jonathan
*/
public final class MessageProcessor {
private EndpointMethod EM;
public static JSONObject getReply(JSONObject data)
private MessageProcessor()
{
JSONObject ret = new JSONObject();
return ret;
EM = new EndpointMethod();
}
private JSONObject statusOK()
public static JSONObject getReply(JSONObject data)
{
JSONObject ret = new JSONObject();
ret.put("status", "ok");
return ret;
}
}
......@@ -9,6 +9,7 @@
* @author Jonathan
*/
import Controller.ConnectionHandler;
import Controller.DBHandler;
import java.io.*;
import java.net.*;
import java.util.Vector;
......@@ -21,24 +22,8 @@ import org.json.simple.parser.ParseException;
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 {
DBHandler.initialize();
ConnectionHandler CH = new ConnectionHandler();
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