Skip to content

Commit

Permalink
Notify connected user of others state
Browse files Browse the repository at this point in the history
  • Loading branch information
streamer45 committed Apr 9, 2021
1 parent 25de7e8 commit b767f30
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions server/signal.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,23 @@ func (p *Plugin) handleWebSocket(w http.ResponseWriter, r *http.Request, channel
"userID": userID,
}, &model.WebsocketBroadcast{ChannelId: channelID})

// notify connected user about other users state.
p.mut.RLock()
for id, session := range p.sessions {
var evType string
if session.isMuted {
evType = wsEventUserMuted
} else {
evType = wsEventUserUnmuted
}
if id != userID {
p.API.PublishWebSocketEvent(evType, map[string]interface{}{
"userID": id,
}, &model.WebsocketBroadcast{ChannelId: channelID, UserId: userID})
}
}
p.mut.RUnlock()

go func() {
defer wg.Done()
for {
Expand Down

0 comments on commit b767f30

Please sign in to comment.