WSMessage object
This commit is contained in:
@ -115,6 +115,13 @@
|
||||
renderCellContent(position, BOARD_ICONS.DESTINATION);
|
||||
}
|
||||
|
||||
function renderGameDump(data) {
|
||||
createBoard(data.board);
|
||||
renderObstacles(data.layers)
|
||||
renderDestination(data.destination.position);
|
||||
renderPlayerList(data.players);
|
||||
renderPlayers(data.players);
|
||||
}
|
||||
|
||||
function wsConnect() {
|
||||
let ws = new WebSocket('ws://localhost:8011');
|
||||
@ -123,14 +130,16 @@
|
||||
};
|
||||
|
||||
ws.onmessage = (e) => {
|
||||
const data = JSON.parse(e.data);
|
||||
console.log("WS message received:", data)
|
||||
const wsMessage = JSON.parse(e.data);
|
||||
console.log("WS message received:", wsMessage)
|
||||
|
||||
createBoard(data.board);
|
||||
renderObstacles(data.layers)
|
||||
renderDestination(data.destination.position);
|
||||
renderPlayerList(data.players);
|
||||
renderPlayers(data.players);
|
||||
switch (wsMessage.message) {
|
||||
case "game_dump":
|
||||
renderGameDump(wsMessage.data);
|
||||
break;
|
||||
default:
|
||||
console.error("Unknown message:", wsMessage)
|
||||
}
|
||||
};
|
||||
|
||||
ws.onclose = (e) => {
|
||||
|
||||
Reference in New Issue
Block a user