Make IsConnectionCanceled available at LocalParticipant interface. (#4643)

Can be used to keep track of pariticpants failing connection in a room
by checking this when room closes the participant.
This commit is contained in:
Raja Subramanian
2026-07-05 16:08:10 +05:30
committed by GitHub
parent 0bc73fd0da
commit bf777e6513
3 changed files with 82 additions and 5 deletions
+9 -5
View File
@@ -1427,19 +1427,23 @@ func (p *ParticipantImpl) IsReconnect() bool {
}
func (p *ParticipantImpl) maybeRecordRTCanceled(closeReason types.ParticipantCloseReason) {
if p.State() >= livekit.ParticipantInfo_ACTIVE {
if p.HasConnected() {
return
}
if closeReason == types.ParticipantCloseReasonClientRequestLeave ||
if p.IsConnectionCanceled(closeReason) {
prometheus.IncrementParticipantRtcCanceled(1)
}
}
func (p *ParticipantImpl) IsConnectionCanceled(closeReason types.ParticipantCloseReason) bool {
return closeReason == types.ParticipantCloseReasonClientRequestLeave ||
closeReason == types.ParticipantCloseReasonDuplicateIdentity ||
closeReason == types.ParticipantCloseReasonRoomClosed ||
closeReason == types.ParticipantCloseReasonMigrationRequested ||
closeReason == types.ParticipantCloseReasonMigrationComplete ||
// client closing signal connection too quickly, there is a time check to handle clients timing out and leaving without sending a leave message
(time.Since(p.params.SessionStartTime) < 3*time.Second && closeReason == types.ParticipantCloseReasonSignalSourceClose) {
prometheus.IncrementParticipantRtcCanceled(1)
}
(time.Since(p.params.SessionStartTime) < 3*time.Second && closeReason == types.ParticipantCloseReasonSignalSourceClose)
}
func (p *ParticipantImpl) Close(sendLeave bool, reason types.ParticipantCloseReason, isExpectedToResume bool) error {