-
Notifications
You must be signed in to change notification settings - Fork 56
Ability to reject an incoming call when you aleady have a ringing or active call #1614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rahul-lohra
wants to merge
14
commits into
develop
Choose a base branch
from
feature/rahullohra/reject-call-when-busy
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0736ec9
feature: reject call when busy
rahul-lohra 5548aa8
feature: write test cases for CallStateRingEvent and CallBusyHandler
rahul-lohra 8dde3cf
fix: simplify logic
rahul-lohra 90d39b6
fix: simplify logic
rahul-lohra a3f017d
fix: simplify logic and write unit tests
rahul-lohra 5148031
fix: set rejectCallWhenBusy to false in demo-app
rahul-lohra 2aa5c86
fix: update kdoc
rahul-lohra e44ef80
chore: update kdoc
rahul-lohra 664b29b
chore: revert function visibility
rahul-lohra f897a14
chore: revert unnecessary changes
rahul-lohra be4cfe6
Merge branch 'develop' into feature/rahullohra/reject-call-when-busy
rahul-lohra 2e3af4d
chore: refactor
rahul-lohra c4e8f16
chore: refactor
rahul-lohra 7f33fbd
Merge branch 'develop' into feature/rahullohra/reject-call-when-busy
aleksandar-apostolov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...eo-android-core/src/main/kotlin/io/getstream/video/android/core/EventPropagationPolicy.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* | ||
| * Copyright (c) 2014-2026 Stream.io Inc. All rights reserved. | ||
| * | ||
| * Licensed under the Stream License; | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://github.com/GetStream/stream-video-android/blob/main/LICENSE | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.getstream.video.android.core | ||
|
|
||
| import io.getstream.android.video.generated.models.CallRingEvent | ||
| import io.getstream.android.video.generated.models.VideoEvent | ||
| import io.getstream.video.android.core.call.CallBusyHandler | ||
|
|
||
| internal class EventPropagationPolicy(private val callBusyHandler: CallBusyHandler) { | ||
| fun shouldPropagate(event: VideoEvent): Boolean { | ||
| return when (event) { | ||
| is CallRingEvent -> callBusyHandler.shouldPropagateEvent(event) | ||
| else -> true | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...ideo-android-core/src/main/kotlin/io/getstream/video/android/core/call/CallBusyHandler.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * Copyright (c) 2014-2026 Stream.io Inc. All rights reserved. | ||
| * | ||
| * Licensed under the Stream License; | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://github.com/GetStream/stream-video-android/blob/main/LICENSE | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.getstream.video.android.core.call | ||
|
|
||
| import io.getstream.android.video.generated.models.CallRingEvent | ||
| import io.getstream.video.android.core.StreamVideoClient | ||
| import io.getstream.video.android.core.model.RejectReason | ||
| import kotlinx.coroutines.launch | ||
|
|
||
| internal class CallBusyHandler(private val streamVideo: StreamVideoClient) { | ||
|
|
||
| fun shouldPropagateEvent(event: CallRingEvent): Boolean { | ||
| return !isBusyWithAnotherCall(event.callCid, true) | ||
| } | ||
|
|
||
| fun isBusyWithAnotherCall(callCid: String, rejectViaApi: Boolean = false): Boolean { | ||
| val clientState = streamVideo.state | ||
| if (!clientState.rejectCallWhenBusy) return false | ||
|
|
||
| val (type, id) = callCid.split(":") | ||
|
|
||
| val isBusy = | ||
| clientState.activeCall.value?.id?.let { it != id } == true || | ||
| clientState.ringingCall.value?.id?.let { it != id } == true | ||
|
|
||
| if (isBusy && rejectViaApi) { | ||
| streamVideo.scope.launch { | ||
| streamVideo.call(type, id).reject(RejectReason.Busy) | ||
| } | ||
| } | ||
|
|
||
| return isBusy | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Silent rejection failure leaves the remote caller ringing indefinitely.
The fire-and-forget
launchswallows any exception fromreject(RejectReason.Busy). If the API call fails (network error, server error, etc.), the caller never receives a busy signal. At minimum, the failure should be logged; ideally it is also surfaced upstream.🛡️ Proposed fix
if (isBusy && rejectViaApi) { streamVideo.scope.launch { - streamVideo.call(type, id).reject(RejectReason.Busy) + streamVideo.call(type, id).reject(RejectReason.Busy) + .onError { error -> + // Log so operators can observe rejection failures + streamLog(priority = StreamLog.WARN) { + "[CallBusyHandler] Failed to reject busy call $callCid: ${error.message}" + } + } } }📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's okay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rahul-lohra, understood! I'll skip this suggestion for error handling in the busy call rejection flow.✏️ Learnings added
🧠 Learnings used