Skip to content

Commit

Permalink
Request game list
Browse files Browse the repository at this point in the history
  • Loading branch information
muktar1907 committed Apr 30, 2024
1 parent a4573e3 commit e79fe5c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
14 changes: 5 additions & 9 deletions html/index_1.html
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,8 @@ <h2>Leaderboard</h2>

function requestGameList() {
var data = { type: "RequestGameList" };
if(socket.readyState===1)
{
socket.send(JSON.stringify(data));
}

socket.send(JSON.stringify(data));
}

function updateGameList(serverData)
Expand Down Expand Up @@ -361,7 +359,7 @@ <h2>Leaderboard</h2>
cell.setAttribute("id",k.toString());


const cellText=document.createTextNode(grid[i][j]);
const cellText=document.createTextNode(grid[i][j].toUpperCase());
cell.appendChild(cellText);
row.appendChild(cell);
}
Expand Down Expand Up @@ -512,10 +510,8 @@ <h2>Leaderboard</h2>
var data={
type: "updateLobby"
}
if(socket.readyState===1)
{
socket.send(JSON.stringify(data));
}
socket.send(JSON.stringify(data));

}
</script>

11 changes: 9 additions & 2 deletions src/main/java/uta/cse3310/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,15 @@ public void messageHandler(Gson gson, String jsonString, WebSocket conn)
jsonObject.addProperty("type","RequestGameList");
//FIX LATER
//does not end up sending the active games
String jsonGameList= gson.toJson(activeGames);
System.out.println(activeGames.toString());
String[] activeGameArr= new String[activeGames.size()];
int j=0;
for(Game i: activeGames)
{
activeGameArr[j]=i.getGameID();
j++;
}
String jsonGameList= gson.toJson(activeGameArr.toString());
System.out.println(activeGameArr.toString());
jsonObject.addProperty("gameList",jsonGameList);
conn.send(jsonObject.toString());
break;
Expand Down

0 comments on commit e79fe5c

Please sign in to comment.