Do not send ParticipantLeft webhook event unless connected successfully. (#1234)

Fixes #1130
This commit is contained in:
David Zhao
2022-12-18 17:37:55 -08:00
committed by GitHub
parent dc3f566f1a
commit 33902a9f2a
9 changed files with 141 additions and 109 deletions
+14
View File
@@ -20,6 +20,7 @@ type StatsWorker struct {
roomName livekit.RoomName
participantID livekit.ParticipantID
participantIdentity livekit.ParticipantIdentity
isConnected bool
lock sync.RWMutex
outgoingPerTrack map[livekit.TrackID][]*livekit.AnalyticsStat
@@ -62,6 +63,19 @@ func (s *StatsWorker) ParticipantID() livekit.ParticipantID {
return s.participantID
}
func (s *StatsWorker) SetConnected() {
s.lock.Lock()
s.isConnected = true
s.lock.Unlock()
}
func (s *StatsWorker) IsConnected() bool {
s.lock.RLock()
defer s.lock.RUnlock()
return s.isConnected
}
func (s *StatsWorker) Flush() {
ts := timestamppb.Now()