Commit ef93e6a6 authored by Rakhmatullah Yoga Sutrisna's avatar Rakhmatullah Yoga Sutrisna
Browse files

coba tracker listener, belum kelar

parent 0046a56f
/src/server/TrialServer/nbproject/private/
/src/server/GrandQuestServer/nbproject/private/
/src/server/GrandQuestServer/build/
/src/server/GrandQuestServer/dist/
\ No newline at end of file
/src/server/GrandQuestServer/dist/
/src/server/DummyClient/nbproject/private/
/src/server/DummyClient/build/
\ No newline at end of file
compile.on.save=true
user.properties.file=C:\\Users\\Lenovo\\AppData\\Roaming\\NetBeans\\8.0\\build.properties
do.depend=false
do.jar=true
javac.debug=true
javadoc.preview=true
user.properties.file=C:\\Users\\Rakhmatullah Yoga S\\AppData\\Roaming\\NetBeans\\8.0\\build.properties
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=DummyClient
application.vendor=Rakhmatullah Yoga S
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
......@@ -26,8 +27,9 @@ dist.archive.excludes=
dist.dir=dist
dist.jar=${dist.dir}/DummyClient.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.json-simple-1.1.1.jar=C:\\Users\\Lenovo\\Documents\\NetBeansProjects\\json-simple-1.1.1.jar
file.reference.json-simple-1.1.1.jar=../GrandQuestServer/lib/json-simple-1.1.1.jar
includes=**
jar.compress=false
javac.classpath=\
......
......@@ -9,9 +9,12 @@ package grandquestserver;
*
* @author Rakhmatullah Yoga S
*/
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.*;
import org.json.simple.*;
import org.json.simple.parser.JSONParser;
import java.util.*;
import org.json.simple.parser.ParseException;
public class JSONParse {
......@@ -25,6 +28,20 @@ public class JSONParse {
return request;
}
/**
* (sementara) yang dipake buat join tracker, isi addressnya masih blm tau itu ip server atau ip tracker
* @param sock
* @return
* @throws UnknownHostException
*/
public Map newServerJSON(Socket sock) throws UnknownHostException {
Map request = new LinkedHashMap();
request.put("method", "join");
request.put("ip", InetAddress.getLocalHost().getHostAddress());
request.put("port", sock.getLocalPort());
return request;
}
//Respon JSON untuk login
public Map loginJSON(boolean valid, String token) {
Map response = new LinkedHashMap();
......
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package grandquestserver;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Rakhmatullah Yoga S
*/
public class TrackerListener extends Thread {
private Socket trackListener;
private final String trackerAddress = "167.205.32.46";
private final int trackerPort = 8000;
public TrackerListener() throws IOException {
trackListener = new Socket(trackerAddress, trackerPort);
}
@Override
public void run() {
try {
System.out.println("Connecting to tracker . . .");
Socket client = new Socket(trackerAddress, trackerPort);
System.out.println("Just connected to tracker!");
OutputStream outToServer = client.getOutputStream();
DataOutputStream out = new DataOutputStream(outToServer);
out.writeUTF(trackerAddress);
} catch (IOException ex) {
Logger.getLogger(TrackerListener.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
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