feat: update playerId handling and improve room rendering logic
All checks were successful
Build and Push Docker Image / docker (push) Successful in 9s
All checks were successful
Build and Push Docker Image / docker (push) Successful in 9s
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user