How to properly manage AntSDK WebSocket connections in Flutter when navigating away from a page #7131
Replies: 3 comments 2 replies
-
I have converted to a discussion to get answers for your questions. |
Beta Was this translation helpful? Give feedback.
-
Hi, @OverRide |
Beta Was this translation helpful? Give feedback.
-
Thank you for the suggestion, but I'm still encountering the issue. I've implemented the solution you provided: @Override
void dispose() {
AntMediaFlutter.anthelper?.close();
super.dispose();
} However, the problem persists specifically when:
In this scenario, it seems the WebSocket connection continues in the background even after the widget is disposed. When the connection eventually completes, it causes audio conflicts when returning to the page. Is there a more specific method to terminate the WebSocket connection while it's still in the "connecting" state? Perhaps something like: @Override
void dispose() {
// Force terminate any pending WebSocket connections?
AntMediaFlutter.anthelper?.forceDisconnect(); // Does something like this exist?
AntMediaFlutter.anthelper?.close();
super.dispose();
} Or should I be managing this differently, perhaps by using a singleton approach with better state management? |
Beta Was this translation helpful? Give feedback.
-
How to properly manage AntSDK WebSocket connections in Flutter when navigating away from a page
Issue
I'm developing a Flutter app using AntSDK and encountering an issue with WebSocket connection management:
What I need:
Terminate the WebSocket connection when navigating away from the page
Completely clear the Ant instance when not in use
Stop all AntSDK-related processes when not on that page
What I've tried
dart
@OverRide
void dispose() {
// I've tried using the standard dispose method but it doesn't solve the issue
super.dispose();
}
Questions
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions