Fix SubParticipant twice when paticipant left (#2672)

This commit is contained in:
cnderrauber
2024-04-23 16:09:02 +08:00
committed by GitHub
parent 8f05385126
commit f239f8bff1
+3 -7
View File
@@ -161,17 +161,13 @@ func (t *telemetryService) ParticipantLeft(ctx context.Context,
) { ) {
t.enqueue(func() { t.enqueue(func() {
isConnected := false isConnected := false
hasWorker := false
if worker, ok := t.getWorker(livekit.ParticipantID(participant.Sid)); ok { if worker, ok := t.getWorker(livekit.ParticipantID(participant.Sid)); ok {
hasWorker = true
isConnected = worker.IsConnected() isConnected = worker.IsConnected()
worker.Close() if worker.ClosedAt().IsZero() {
}
if hasWorker {
// signifies we had incremented participant count
prometheus.SubParticipant() prometheus.SubParticipant()
} }
worker.Close()
}
if isConnected && shouldSendEvent { if isConnected && shouldSendEvent {
t.NotifyEvent(ctx, &livekit.WebhookEvent{ t.NotifyEvent(ctx, &livekit.WebhookEvent{