-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marcus Lankenau
committed
May 12, 2011
1 parent
22182c6
commit 2a9f5c3
Showing
10 changed files
with
124 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.galaxy; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.net.InetAddress; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.net.URLConnection; | ||
|
||
public class GameInitiator { | ||
Remote remote = null; | ||
|
||
public static final String BASE_SERVER_URL = "http://sharp-fog-360.heroku.com"; | ||
|
||
String baseUrl = BASE_SERVER_URL; | ||
|
||
|
||
protected static String httpGet(String address) throws Exception { | ||
URL url = new URL(address); | ||
URLConnection yc = url.openConnection(); | ||
BufferedReader in = new BufferedReader( | ||
new InputStreamReader( | ||
yc.getInputStream())); | ||
String inputLine; | ||
|
||
StringBuffer resultBuffer = new StringBuffer(); | ||
while ((inputLine = in.readLine()) != null) | ||
resultBuffer.append(inputLine+ "\n"); | ||
in.close(); | ||
|
||
return resultBuffer.toString(); | ||
} | ||
|
||
|
||
protected static void enlist(String url, int port, String name) throws Exception { | ||
String cmdUrl = url + "/enlist/" + InetAddress.getLocalHost().getHostAddress() + "?name="+name + "&port="+port; | ||
httpGet(cmdUrl); | ||
|
||
} | ||
|
||
protected static String getPlayers(String url) throws Exception { | ||
//URL urlConnection = new URL(url + "/players"); | ||
//String result = readStream((InputStream)urlConnection.openStream()); | ||
|
||
return httpGet(url + "/players"); | ||
} | ||
|
||
|
||
|
||
public GameInitiator(String name) { | ||
|
||
} | ||
|
||
|
||
public void startMultiplayer() { | ||
//getPlayers(baseUrl); | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.galaxy; | ||
|
||
import org.junit.Test; | ||
|
||
public class GameInitiatorTest extends GameInitiator{ | ||
String LOCAL_TEST_SERVER = "http://localhost:8090"; | ||
|
||
public GameInitiatorTest() { | ||
super("tralala"); | ||
} | ||
|
||
@Test | ||
public void testServer() throws Exception { | ||
enlist(LOCAL_TEST_SERVER, 1001, "marcus"); | ||
enlist(LOCAL_TEST_SERVER, 1002, "sebastian"); | ||
|
||
String players = getPlayers(LOCAL_TEST_SERVER); | ||
System.out.println("players: " + players); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry exported="true" kind="lib" path="httpclient-4.1.1.jar"/> | ||
<classpathentry exported="true" kind="lib" path="json_simple-1.1.jar"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>libs</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#Thu May 12 16:16:25 CEST 2011 | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.6 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.6 |
Binary file not shown.
Binary file not shown.