Skip to content
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

Feature request: add cancellation support for TransferSIPParticipant API #277

Open
shwetd19 opened this issue Feb 6, 2025 · 0 comments
Open

Comments

@shwetd19
Copy link

shwetd19 commented Feb 6, 2025

CC : @mike-r-mclaughlin

Description

Currently, there's no mechanism to cancel an ongoing TransferSIPParticipant() operation after it has been initiated. This leads to race conditions and conflicting states when users change their mind mid-transfer or when the system needs to handle interruptions.

Current Behavior

When TransferSIPParticipant() is called:

  • The transfer process begins immediately
  • There's no way to stop or cancel the transfer
  • Any subsequent operations (like starting a new workflow) can run concurrently with the transfer
  • This can lead to undefined behavior and poor user experience

Example Scenario

User: "I need billing"
System: Initiates TransferSIPParticipant() to billing department
User: "Wait, actually I want to schedule an appointment"
System: Starts appointment scheduling workflow
[Problem: Transfer continues in background while appointment scheduling begins]

Proposed Solution

Add a cancellation mechanism for TransferSIPParticipant() that could work in one of these ways:

  1. Cancel Method:
transfer = await room.TransferSIPParticipant(...)
await transfer.cancel()  # New method
  1. Context Manager Approach:
with await room.TransferSIPParticipant(...) as transfer:
    try:
        # Transfer in progress
    except UserInterruption:
        await transfer.cancel()
  1. Cancellation Token:
cancellation_token = CancellationToken()
await room.TransferSIPParticipant(..., cancellation_token=cancellation_token)
# Later when needed:
cancellation_token.cancel()

Technical Considerations

Implementation Requirements

  1. Thread-safe cancellation mechanism
  2. Proper cleanup of resources
  3. Clear state management during cancellation
  4. Event notifications for cancellation status

Edge Cases to Handle

  • Cancellation during different stages of transfer
  • Multiple rapid cancel requests
  • Partial transfer states
  • Resource cleanup
  • Connection handling

This request comes from production usage where voice assistants need to handle dynamic user interactions and change of intent during transfers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant