simplify vls base access (#3465)

This commit is contained in:
Paul Wells
2025-02-26 09:34:59 +05:30
committed by GitHub
parent 7350e99331
commit 43bd251575
6 changed files with 16 additions and 60 deletions
+5 -7
View File
@@ -871,24 +871,24 @@ func (r *Room) IsClosed() bool {
}
// CloseIfEmpty closes the room if all participants had left, or it's still empty past timeout
func (r *Room) CloseIfEmpty() string {
func (r *Room) CloseIfEmpty() {
r.lock.Lock()
if r.IsClosed() || r.holds.Load() > 0 {
r.lock.Unlock()
return ""
return
}
for _, p := range r.participants {
if !p.IsDependent() {
r.lock.Unlock()
return ""
return
}
}
var timeout uint32
var elapsed int64
reason := ""
var reason string
if r.FirstJoinedAt() > 0 && r.LastLeftAt() > 0 {
elapsed = time.Now().Unix() - r.LastLeftAt()
// need to give time in case participant is reconnecting
@@ -903,10 +903,8 @@ func (r *Room) CloseIfEmpty() string {
if elapsed >= int64(timeout) {
r.Close(types.ParticipantCloseReasonRoomClosed)
return reason
r.Logger.Infow("closing idle room", "reason", reason)
}
return ""
}
func (r *Room) Close(reason types.ParticipantCloseReason) {