Close room if recorder is the only participant left, not hidden. (#787)

Also need to close participant connections
This commit is contained in:
David Zhao
2022-06-24 15:49:02 -07:00
committed by GitHub
parent 46bce33fb8
commit 16505e2ce9
+4 -1
View File
@@ -508,7 +508,7 @@ func (r *Room) CloseIfEmpty() {
} }
for _, p := range r.participants { for _, p := range r.participants {
if !p.Hidden() { if !p.IsRecorder() {
r.lock.Unlock() r.lock.Unlock()
return return
} }
@@ -544,6 +544,9 @@ func (r *Room) Close() {
close(r.closed) close(r.closed)
r.lock.Unlock() r.lock.Unlock()
r.Logger.Infow("closing room") r.Logger.Infow("closing room")
for _, p := range r.GetParticipants() {
_ = p.Close(true, types.ParticipantCloseReasonRoomClose)
}
if r.onClose != nil { if r.onClose != nil {
r.onClose() r.onClose()
} }