feat: update playerId handling and improve room rendering logic
All checks were successful
Build and Push Docker Image / docker (push) Successful in 9s

This commit is contained in:
2025-09-05 11:51:38 +02:00
parent 12113ec1ce
commit 24c8c41f1e
7 changed files with 362 additions and 329 deletions

View File

@@ -127,13 +127,17 @@ export function setupWebSocket(server) {
if (foundRoom.state.spectators) delete foundRoom.state.spectators[found.id];
found.spectator = false;
}
// Notify room
broadcast(foundRoom, 'room_update', { room: roomSummary(foundRoom) });
}
// Send resume result and an explicit connected that preserves their original session.
// Send resume result and an explicit connected that preserves their original session
// BEFORE broadcasting room_update. This ensures the client sets playerId before
// rendering the first room snapshot.
send('resume_result', { ok: true, playerId: found.id, roomId: foundRoom?.id });
helloSent = true;
send('connected', { playerId: found.id, sessionId: found.sessionId });
if (foundRoom) {
// Now notify the room (and the resumed client) of the updated presence
broadcast(foundRoom, 'room_update', { room: roomSummary(foundRoom) });
}
return;
}