Make an IsDisconnected interface and use it (#1278)

This commit is contained in:
Raja Subramanian
2022-12-31 12:53:02 +05:30
committed by GitHub
parent 9b8311ffcb
commit 4ba7e57683
7 changed files with 86 additions and 81 deletions
+6 -1
View File
@@ -66,6 +66,11 @@ func (p *ParticipantImpl) SendJoinResponse(joinResponse *livekit.JoinResponse) e
func (p *ParticipantImpl) SendParticipantUpdate(participantsToUpdate []*livekit.ParticipantInfo) error {
p.updateLock.Lock()
if p.IsDisconnected() {
p.updateLock.Unlock()
return nil
}
if !p.IsReady() {
// queue up updates
p.queuedUpdates = append(p.queuedUpdates, participantsToUpdate...)
@@ -201,7 +206,7 @@ func (p *ParticipantImpl) sendTrackUnpublished(trackID livekit.TrackID) {
}
func (p *ParticipantImpl) writeMessage(msg *livekit.SignalResponse) error {
if p.State() == livekit.ParticipantInfo_DISCONNECTED || (!p.IsReady() && msg.GetJoin() == nil) {
if p.IsDisconnected() || (!p.IsReady() && msg.GetJoin() == nil) {
return nil
}