Skip to content

Commit

Permalink
Created httpserver and websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
NotVeridion committed Apr 12, 2024
1 parent 9b02d37 commit bfff3a0
Show file tree
Hide file tree
Showing 22 changed files with 103 additions and 15 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

<dependencies>
Expand Down
33 changes: 23 additions & 10 deletions src/main/java/com/cse3310/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public class App extends WebSocketServer
int GameID;

public App(int port){

super(new InetSocketAddress(port));
}

public App(InetSocketAddress address){

super(address);
}

public App(int port, Draft_6455 draft){

super(new InetSocketAddress(port), Collections.<Draft>singletonList(draft));
}

@Override
Expand Down Expand Up @@ -77,19 +77,32 @@ public void onMessage(WebSocket conn, String message) {

@Override
public void onError(WebSocket conn, Exception ex) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'onError'");
ex.printStackTrace();
if (conn != null) {
// some errors like port binding failed may not be assignable to a specific
// websocket
}
}

@Override
public void onStart() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'onStart'");
System.out.println("Server started!");
setConnectionLostTimeout(0);
}



public static void main(String[] args) {

// Set up the http server
String envPort = System.getenv("HTTP_PORT");
int httpPort = Integer.parseInt(envPort);
HttpServer H = new HttpServer(httpPort, "./html");
H.start();
System.out.println("http Server started on port:" + httpPort);

// create and start the websocket server
envPort = System.getenv("WEBSOCKET_PORT");
int socketPort = Integer.parseInt("envPort");
App A = new App(socketPort);
A.start();
System.out.println("websocket Server started on port: " + socketPort);
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/cse3310/Coordinate.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Coordinate {
public int x;
public int y;

public void Coordinate(int x, int y){
public Coordinate(int x, int y){
this.x = x;
this.y = y;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cse3310/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void checkWin(User user){

}

public String keepScore(ArrayList score){
public String keepScore(ArrayList<User> score){

return "";
}
Expand Down
Binary file modified target/classes/com/cse3310/App.class
Binary file not shown.
Binary file modified target/classes/com/cse3310/Coordinate.class
Binary file not shown.
Binary file modified target/classes/com/cse3310/Game.class
Binary file not shown.
Binary file modified target/classes/com/cse3310/HttpServer$1.class
Binary file not shown.
Binary file modified target/classes/com/cse3310/HttpServer.class
Binary file not shown.
Binary file modified target/classes/com/cse3310/Locations.class
Binary file not shown.
Binary file modified target/classes/com/cse3310/ServerEvent.class
Binary file not shown.
Binary file modified target/classes/com/cse3310/User.class
Binary file not shown.
Binary file modified target/classes/com/cse3310/UserEvent.class
Binary file not shown.
Binary file added target/cse3310-wordsearch.jar
Binary file not shown.
4 changes: 4 additions & 0 deletions target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Created by Apache Maven 3.9.6
artifactId=cse3310
groupId=com.cse3310_sp24_group26
version=wordsearch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
com/cse3310/Coordinate.class
com/cse3310/ServerEvent.class
com/cse3310/Locations.class
com/cse3310/HttpServer.class
com/cse3310/HttpServer$1.class
com/cse3310/UserEvent.class
com/cse3310/User.class
com/cse3310/App.class
com/cse3310/Game.class
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@
/workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/User.java
/workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/Locations.java
/workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/App.java
/workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/WebSocket.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com/cse3310/AppTest.class
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/workspaces/cse3310_sp24_group_26/src/test/java/com/cse3310/AppTest.java
57 changes: 57 additions & 0 deletions target/surefire-reports/TEST-com.cse3310.AppTest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd" name="com.cse3310.AppTest" time="0.051" tests="1" errors="0" skipped="0" failures="0">
<properties>
<property name="java.specification.version" value="21"/>
<property name="sun.jnu.encoding" value="UTF-8"/>
<property name="java.class.path" value="/workspaces/cse3310_sp24_group_26/target/test-classes:/workspaces/cse3310_sp24_group_26/target/classes:/home/codespace/.m2/repository/junit/junit/4.11/junit-4.11.jar:/home/codespace/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/home/codespace/.m2/repository/com/google/code/gson/gson/2.9.1/gson-2.9.1.jar:/home/codespace/.m2/repository/net/freeutils/jlhttp/2.6/jlhttp-2.6.jar:/home/codespace/.m2/repository/org/java-websocket/Java-WebSocket/1.5.4/Java-WebSocket-1.5.4.jar:/home/codespace/.m2/repository/org/slf4j/slf4j-api/2.0.6/slf4j-api-2.0.6.jar:"/>
<property name="java.vm.vendor" value="Microsoft"/>
<property name="sun.arch.data.model" value="64"/>
<property name="java.vendor.url" value="https://www.microsoft.com"/>
<property name="os.name" value="Linux"/>
<property name="java.vm.specification.version" value="21"/>
<property name="sun.java.launcher" value="SUN_STANDARD"/>
<property name="sun.boot.library.path" value="/usr/local/sdkman/candidates/java/21.0.2-ms/lib"/>
<property name="sun.java.command" value="/workspaces/cse3310_sp24_group_26/target/surefire/surefirebooter8281021882678477452.jar /workspaces/cse3310_sp24_group_26/target/surefire 2024-04-12T20-36-55_134-jvmRun1 surefire4760148764593947802tmp surefire_05438940052446170441tmp"/>
<property name="jdk.debug" value="release"/>
<property name="surefire.test.class.path" value="/workspaces/cse3310_sp24_group_26/target/test-classes:/workspaces/cse3310_sp24_group_26/target/classes:/home/codespace/.m2/repository/junit/junit/4.11/junit-4.11.jar:/home/codespace/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/home/codespace/.m2/repository/com/google/code/gson/gson/2.9.1/gson-2.9.1.jar:/home/codespace/.m2/repository/net/freeutils/jlhttp/2.6/jlhttp-2.6.jar:/home/codespace/.m2/repository/org/java-websocket/Java-WebSocket/1.5.4/Java-WebSocket-1.5.4.jar:/home/codespace/.m2/repository/org/slf4j/slf4j-api/2.0.6/slf4j-api-2.0.6.jar:"/>
<property name="sun.cpu.endian" value="little"/>
<property name="user.home" value="/home/codespace"/>
<property name="user.language" value="en"/>
<property name="java.specification.vendor" value="Oracle Corporation"/>
<property name="java.version.date" value="2024-01-16"/>
<property name="java.home" value="/usr/local/sdkman/candidates/java/21.0.2-ms"/>
<property name="file.separator" value="/"/>
<property name="basedir" value="/workspaces/cse3310_sp24_group_26"/>
<property name="java.vm.compressedOopsMode" value="32-bit"/>
<property name="line.separator" value="&#10;"/>
<property name="java.specification.name" value="Java Platform API Specification"/>
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
<property name="surefire.real.class.path" value="/workspaces/cse3310_sp24_group_26/target/surefire/surefirebooter8281021882678477452.jar"/>
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
<property name="java.runtime.version" value="21.0.2+13-LTS"/>
<property name="user.name" value="codespace"/>
<property name="stdout.encoding" value="UTF-8"/>
<property name="path.separator" value=":"/>
<property name="os.version" value="6.2.0-1019-azure"/>
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
<property name="file.encoding" value="UTF-8"/>
<property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/>
<property name="java.vendor.version" value="Microsoft-8905927"/>
<property name="localRepository" value="/home/codespace/.m2/repository"/>
<property name="java.vendor.url.bug" value="https://github.com/microsoft/openjdk/issues"/>
<property name="java.io.tmpdir" value="/tmp"/>
<property name="java.version" value="21.0.2"/>
<property name="user.dir" value="/workspaces/cse3310_sp24_group_26"/>
<property name="os.arch" value="amd64"/>
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
<property name="native.encoding" value="UTF-8"/>
<property name="java.library.path" value="/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib"/>
<property name="java.vm.info" value="mixed mode, sharing"/>
<property name="stderr.encoding" value="UTF-8"/>
<property name="java.vendor" value="Microsoft"/>
<property name="java.vm.version" value="21.0.2+13-LTS"/>
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
<property name="java.class.version" value="65.0"/>
</properties>
<testcase name="shouldAnswerWithTrue" classname="com.cse3310.AppTest" time="0.003"/>
</testsuite>
4 changes: 4 additions & 0 deletions target/surefire-reports/com.cse3310.AppTest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-------------------------------------------------------------------------------
Test set: com.cse3310.AppTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.051 s - in com.cse3310.AppTest
Binary file modified target/test-classes/com/cse3310/AppTest.class
Binary file not shown.

0 comments on commit bfff3a0

Please sign in to comment.