mirror of
https://github.com/strukturag/nextcloud-spreed-signaling.git
synced 2023-10-21 07:33:40 -05:00
Only send single "incall" message with "all: true" in clustered setup.
Previously each instance would send one message to all users in the cluster.
This commit is contained in:
@@ -692,11 +692,13 @@ func (r *Room) PublishUsersInCallChangedAll(inCall int) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
var notify []*ClientSession
|
||||
if inCall&FlagInCall != 0 {
|
||||
// All connected sessions join the call.
|
||||
var joined []string
|
||||
for _, session := range r.sessions {
|
||||
if _, ok := session.(*ClientSession); !ok {
|
||||
clientSession, ok := session.(*ClientSession)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -708,6 +710,7 @@ func (r *Room) PublishUsersInCallChangedAll(inCall int) {
|
||||
r.inCallSessions[session] = true
|
||||
joined = append(joined, session.PublicId())
|
||||
}
|
||||
notify = append(notify, clientSession)
|
||||
}
|
||||
|
||||
if len(joined) == 0 {
|
||||
@@ -729,6 +732,15 @@ func (r *Room) PublishUsersInCallChangedAll(inCall int) {
|
||||
}
|
||||
}()
|
||||
|
||||
for _, session := range r.sessions {
|
||||
clientSession, ok := session.(*ClientSession)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
notify = append(notify, clientSession)
|
||||
}
|
||||
|
||||
for session := range r.inCallSessions {
|
||||
if clientSession, ok := session.(*ClientSession); ok {
|
||||
ch <- clientSession
|
||||
@@ -755,8 +767,11 @@ func (r *Room) PublishUsersInCallChangedAll(inCall int) {
|
||||
},
|
||||
},
|
||||
}
|
||||
if err := r.publish(message); err != nil {
|
||||
log.Printf("Could not publish incall message in room %s: %s", r.Id(), err)
|
||||
|
||||
for _, session := range notify {
|
||||
if !session.SendMessage(message) {
|
||||
log.Printf("Could not send incall message from room %s to %s", r.Id(), session.PublicId())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user