Skip to content

Commit

Permalink
[Update] userId 받기
Browse files Browse the repository at this point in the history
  • Loading branch information
ChungO5 committed Jan 13, 2024
1 parent 5845f87 commit 7356e6a
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions game-server/src/main/resources/static/2048.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ var tableID = Array(
Array("30", "31", "32", "33")
);
var score;
var userId = "";
window.addEventListener("message", function (event) {
document.getElementById("receivedData").textContent = event.data;
userId = event.data;
});

// 키보드 입력 처리
document.onkeydown = keyDownEventHandler;
Expand Down Expand Up @@ -269,18 +274,22 @@ function gameover() {
"\n최종점수 : " +
finalScore
);
fetch("http://54.210.228.54:8080/log", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
userId: "1",
gameId: 54,
gameScore: score + getMaxNum(),
}),
}).then((response) => {
console.log(response);
});
init();
if (userId === null) {
init();
} else {
fetch("http://54.210.228.54:8080/log", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
userId: userId,
gameId: 54,
gameScore: score + getMaxNum(),
}),
}).then((response) => {
console.log(response);
});
init();
}
}

0 comments on commit 7356e6a

Please sign in to comment.