Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions backend/websocket/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down