fix: ghost players on back - leaveRoom, store.reset, dynamic lobby slots
This commit is contained in:
1 parent
6e384d5985
commit
c7672b1793
5 files changed
+86
-20
No files matched your search
@@ -119,6 +119,19 @@ io.on('connection', (socket) => {
|
||||
}
|
||||
})
|
||||
|
||||
// ─── Quitter une salle explicitement (bouton retour) ────────────────────────
|
||||
socket.on('leave-room', ({ roomId }) => {
|
||||
const room = rooms.get(roomId)
|
||||
if (room) {
|
||||
room.removePlayer(socket.id)
|
||||
socket.leave(roomId)
|
||||
io.to(roomId).emit('room-update', { players: room.getPlayersInfo() })
|
||||
if (room.playerCount === 0) rooms.delete(roomId)
|
||||
console.log(`[${roomId}] ${socket.data.playerName ?? socket.id} a quitté`)
|
||||
}
|
||||
socket.data.roomId = null
|
||||
})
|
||||
|
||||
// ─── Déconnexion ─────────────────────────────────────────────────────────────
|
||||
socket.on('disconnect', () => {
|
||||
const roomId = socket.data.roomId
|
||||
|
||||
Reference in new issue
Block a user