Skip to content

Commit

Permalink
Bug fixed and removed WebSocket.java
Browse files Browse the repository at this point in the history
  • Loading branch information
NotVeridion committed Apr 11, 2024
1 parent 675c805 commit 9b02d37
Show file tree
Hide file tree
Showing 19 changed files with 105 additions and 115 deletions.
50 changes: 50 additions & 0 deletions src/main/java/com/cse3310/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,56 @@ public App(int port, Draft_6455 draft){

}

@Override
public void onOpen(WebSocket conn, ClientHandshake handshake) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'onOpen'");
}

@Override
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'onClose'");
}

@Override
public void onMessage(WebSocket conn, String message) {
// TODO Auto-generated method stub
System.out.println(conn + ": " + message); // Log message in console

// Bring in the data from the webpage
// A UserEvent is all that is allowed at this point
GsonBuilder builder = new GsonBuilder();
Gson gson = builder.create();
UserEvent U = gson.fromJson(message, UserEvent.class);
System.out.println(U.Button);

// Get our Game Object
Game G = conn.getAttachment();
G.Update(U);

// send out the game state every time
// to everyone
String jsonString;
jsonString = gson.toJson(G);

System.out.println(jsonString);
broadcast(jsonString);
throw new UnsupportedOperationException("Unimplemented method 'onMessage'");
}

@Override
public void onError(WebSocket conn, Exception ex) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'onError'");
}

@Override
public void onStart() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'onStart'");
}



public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public void Coordinate(int x, int y){
this.y = y;
}

public void getCoordinate(){
return int[] location = new int[] {x, y};
public int[] getCoordinate(){
int[] location = new int[] {this.x, this.y};
return location;
}
}
39 changes: 0 additions & 39 deletions src/main/java/com/cse3310/Game.Java

This file was deleted.

43 changes: 43 additions & 0 deletions src/main/java/com/cse3310/Game.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.cse3310;

import java.util.ArrayList;

public class Game{
private ArrayList<User> users;
public int GameId;
public int[][] grid;

public Game()
{

}

public boolean checkVertical(ArrayList<User> selectedLetters, int length){
return true;
}

public boolean checkDiagonal(ArrayList<User> selectedLetters, int length){
return true;
}

public boolean checkHorizontal(ArrayList<User> selectedLetters, int length){
return true;
}

public void Update(UserEvent U){

}

public void checkWin(User user){

}

public String keepScore(ArrayList score){

return "";
}

public void Tick(){

}
}
6 changes: 3 additions & 3 deletions src/main/java/com/cse3310/Locations.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import java.util.HashMap;

class Locations {
static HashMap <String, Coordinate[]> locationMap;
public HashMap <String, Coordinate[]> locationMap;

public int[] getStart(String s){
return (locationMap.get(s)[0]).getCoordinate;
return (locationMap.get(s)[0]).getCoordinate();
}

public int[] getEnd(String s){
return (locationMap.get(s)[1]).getCoordinate;
return (locationMap.get(s)[1]).getCoordinate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public User(String username)
this.gameWon = 0;
}

public void setName(string newUsername){
public void setName(String newUsername){

this.username = newUsername;

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/cse3310/UserEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

public class UserEvent {
int GameId;
User UserId;
int UserId;
int Button[][];
String message;
}
68 changes: 0 additions & 68 deletions src/main/java/com/cse3310/WebSocket.java

This file was deleted.

Binary file added target/classes/com/cse3310/App.class
Binary file not shown.
Binary file added target/classes/com/cse3310/Coordinate.class
Binary file not shown.
Binary file added target/classes/com/cse3310/Game.class
Binary file not shown.
Binary file added target/classes/com/cse3310/HttpServer$1.class
Binary file not shown.
Binary file added target/classes/com/cse3310/HttpServer.class
Binary file not shown.
Binary file added target/classes/com/cse3310/Locations.class
Binary file not shown.
Binary file added target/classes/com/cse3310/ServerEvent.class
Binary file not shown.
Binary file added target/classes/com/cse3310/User.class
Binary file not shown.
Binary file added target/classes/com/cse3310/UserEvent.class
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/Game.java
/workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/HttpServer.java
/workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/Coordinate.java
/workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/ServerEvent.java
/workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/UserEvent.java
/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
Binary file added target/test-classes/com/cse3310/AppTest.class
Binary file not shown.

0 comments on commit 9b02d37

Please sign in to comment.