From ce0bdd9dc67f9a0d5b790d7491df99cfdf0379f7 Mon Sep 17 00:00:00 2001 From: td Date: Fri, 27 Jan 2023 17:16:41 +0530 Subject: [PATCH] fix: only send call reject event when needed This is fixes rejects by missed calls, which should only reject a new call locally and not send a event if they are already in a call --- lib/src/voip/README.md | 2 ++ lib/src/voip/call.dart | 6 ++++-- lib/src/voip/voip.dart | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/src/voip/README.md b/lib/src/voip/README.md index f47911a3..7b864d8b 100644 --- a/lib/src/voip/README.md +++ b/lib/src/voip/README.md @@ -133,6 +133,8 @@ newCall.answer(); newCall.reject(); ``` +To reject a call locally but not send a event, use `newCall.reject(shouldEmit: false)` + ### 5.Render media stream The basic process of rendering a video stream is as follow code. diff --git a/lib/src/voip/call.dart b/lib/src/voip/call.dart index 23e0d99e..dad5fd5d 100644 --- a/lib/src/voip/call.dart +++ b/lib/src/voip/call.dart @@ -1022,8 +1022,10 @@ class CallSession { } Logs().d('[VOIP] Rejecting call: $callId'); await terminate(CallParty.kLocal, CallErrorCode.UserHangup, shouldEmit); - await sendCallReject( - room, callId, Timeouts.lifetimeMs, localPartyId, reason); + if (shouldEmit) { + await sendCallReject( + room, callId, Timeouts.lifetimeMs, localPartyId, reason); + } } Future hangup([String? reason, bool suppressEvent = false]) async { diff --git a/lib/src/voip/voip.dart b/lib/src/voip/voip.dart index 63e9a1ba..4aab75e1 100644 --- a/lib/src/voip/voip.dart +++ b/lib/src/voip/voip.dart @@ -224,8 +224,8 @@ class VoIP { if (!delegate.canHandleNewCall && (confId == null || confId != currentGroupCID)) { Logs().v( - '[glare] [VOIP] onCallInvite: Unable to handle new calls, maybe user is busy.'); - await newCall.reject(reason: 'busy', shouldEmit: false); + '[VOIP] onCallInvite: Unable to handle new calls, maybe user is busy.'); + await newCall.reject(reason: CallErrorCode.UserBusy, shouldEmit: false); delegate.handleMissedCall(newCall); return; }