Skip to content

feat(twilio): add OnStreamingStopped, raised once whenever a media stream ends - #1506

Merged
yileicn merged 2 commits into
SciSharp:masterfrom
yileicn:feat/twilio-streaming-stopped-hook
Nov 20, 2026
Merged

yileicn merged 2 commits into
SciSharp:masterfrom
yileicn:feat/twilio-streaming-stopped-hook

Conversation

@yileicn

@yileicn yileicn commented Nov 20, 2026

Copy link
Copy Markdown
Member

A realtime stream has no hang-up or transfer event: both redirect the call, and the stream only gets a "stop" with no reason. OnStreamingStopped runs in a finally around the receive loop, so it covers "stop", a dropped WebSocket and a failed loop, while the stream's request scope is still alive.

Also notes which hooks each mode raises, and drops the empty HandleUserDisconnected.

…ream ends

A realtime stream has no hang-up or transfer event: both redirect the call, and the
stream only gets a "stop" with no reason. OnStreamingStopped runs in a finally around
the receive loop, so it covers "stop", a dropped WebSocket and a failed loop, while the
stream's request scope is still alive.

Also notes which hooks each mode raises, and drops the empty HandleUserDisconnected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An active moderate issue remains because an exception from the streaming-stop callback can skip state persistence and session disconnection, risking stranded sessions and lost final state.

1 open issue
What changed in this PR

Adds a terminal lifecycle hook for Twilio realtime media streams so integrations are notified whenever a stream ends, including normal stops, dropped WebSockets, and receive-loop failures.

Changes:

  • Adds OnStreamingStopped to ITwilioSessionHook.
  • Invokes the hook when the realtime receive loop terminates.
  • Documents mode-specific hook behavior and removes the unused disconnect handler.
File Description
src/​Plugins/​BotSharp.Plugin.Twilio/​TwilioStreamMiddleware.cs Emits the stream-stopped lifecycle callback when a realtime media stream terminates and removes the unused disconnect handler.
src/​Plugins/​BotSharp.Plugin.Twilio/​Interfaces/​ITwilioSessionHook.cs Defines and documents OnStreamingStopped and clarifies hook behavior across Twilio session modes.

Review effort: Lite

…ate save and disconnect

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yileicn
yileicn merged commit 5efb295 into SciSharp:master Nov 20, 2026
3 of 4 checks passed
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

Successfully merging this pull request may close these issues.

2 participants