diff --git a/backend/websocket/websocket.go b/backend/websocket/websocket.go index 589a6c5..b88f126 100644 --- a/backend/websocket/websocket.go +++ b/backend/websocket/websocket.go @@ -664,15 +664,17 @@ func handleTopicChange(room *Room, conn *websocket.Conn, message Message, roomID // handleRoleSelection handles role selection func handleRoleSelection(room *Room, conn *websocket.Conn, message Message, roomID string) { - // Store the role in the client + // Store the role in the client, releasing the lock before broadcasting + // since snapshotRecipients and broadcastParticipants lock room.Mutex themselves room.Mutex.Lock() - defer room.Mutex.Unlock() if client, exists := room.Clients[conn]; exists { if client.IsSpectator { + room.Mutex.Unlock() return } client.Role = message.Role } + room.Mutex.Unlock() // Broadcast role selection to other clients for _, r := range snapshotRecipients(room, conn) {