mirror of
https://github.com/randyjc/Rahoot.git
synced 2026-03-13 20:15:35 +01:00
Emit total players count to clients in the room on player join and kick events
This commit is contained in:
@@ -56,6 +56,9 @@ const Player = {
|
||||
|
||||
game.players.push(playerData)
|
||||
|
||||
// Emit total players to all players in the room
|
||||
io.to(player.room).emit("game:totalPlayers", game.players.length)
|
||||
|
||||
socket.emit("game:successJoin")
|
||||
},
|
||||
|
||||
@@ -82,6 +85,8 @@ const Player = {
|
||||
data: { text: "Waiting for the players to answer" },
|
||||
})
|
||||
socket.to(game.room).emit("game:playerAnswer", game.playersAnswer.length)
|
||||
// Also emit total players to keep the UI updated
|
||||
io.to(game.room).emit("game:totalPlayers", game.players.length)
|
||||
|
||||
if (game.playersAnswer.length === game.players.length) {
|
||||
abortCooldown()
|
||||
|
||||
Reference in New Issue
Block a user