feat: ice断开返回配置页面

This commit is contained in:
2026-07-14 14:41:42 +08:00
parent 37fccec6af
commit 67c7e48190
3 changed files with 31 additions and 0 deletions

View File

@@ -29,6 +29,9 @@ class WebRtcController {
void Function(String error)? onConnectionFailed;
void Function()? onDisconnected;
/// ICE 连接断开(如网络中断、被控端退出),用于提示用户并返回连接设置。
void Function(String message)? onIceDisconnected;
/// 远端视频流就绪renderer 已绑定视频轨道)。
void Function(RTCVideoRenderer renderer)? onRemoteStream;
@@ -124,7 +127,10 @@ class WebRtcController {
print('ICE connection state: $state');
if (state == RTCIceConnectionState.RTCIceConnectionStateConnected) {
onConnectionEstablished?.call();
} else if (state == RTCIceConnectionState.RTCIceConnectionStateDisconnected) {
onIceDisconnected?.call('ICE 连接已断开');
} else if (state == RTCIceConnectionState.RTCIceConnectionStateFailed) {
onConnectionFailed?.call('ICE 连接失败');
onDisconnected?.call();
}
}