fix(chess): send game updates to move sender + responsive mobile redesign
Some checks failed
Deploy to Production / test (push) Failing after 32s
Some checks failed
Deploy to Production / test (push) Failing after 32s
Bun's ws.publish() excludes the sender, so the player making a move never received the GAME_UPDATE with the new FEN — causing pieces to snap back. Added ctx.send() alongside ctx.publish() for GAME_UPDATE and GAME_ENDED. Also redesigned the panel for mobile: hamburger drawer sidebar, responsive chess board sizing via ResizeObserver, stacked layouts on small screens, and touch-friendly modals/controls across lobby and game pages. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -77,15 +77,19 @@ export function handleGameMessage(msg: GameWsClientMessage, ctx: WsContext): voi
|
||||
}
|
||||
|
||||
const spectatorView = roomManager.getSpectatorView(msg.roomId);
|
||||
ctx.publish(`room:${msg.roomId}`, JSON.stringify({ type: "GAME_UPDATE", roomId: msg.roomId, state: spectatorView }));
|
||||
const updateMsg = JSON.stringify({ type: "GAME_UPDATE", roomId: msg.roomId, state: spectatorView });
|
||||
ctx.publish(`room:${msg.roomId}`, updateMsg);
|
||||
ctx.send(updateMsg);
|
||||
|
||||
if (result.gameOver) {
|
||||
ctx.publish(`room:${msg.roomId}`, JSON.stringify({
|
||||
const endedMsg = JSON.stringify({
|
||||
type: "GAME_ENDED",
|
||||
roomId: msg.roomId,
|
||||
winner: result.gameOver.winner,
|
||||
reason: result.gameOver.reason,
|
||||
}));
|
||||
});
|
||||
ctx.publish(`room:${msg.roomId}`, endedMsg);
|
||||
ctx.send(endedMsg);
|
||||
ctx.publish("lobby", JSON.stringify({ type: "ROOM_LIST_UPDATE", rooms: roomManager.listRooms() }));
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user