|
|
|
@ -829,6 +829,60 @@ class CallController extends GetxController { |
|
|
|
'📞 [CallController] 处理callStatus变化: callStatus=$callStatus, channelId=$channelId', |
|
|
|
); |
|
|
|
|
|
|
|
// 对于 cancelled 和 terminated 状态,即使没有 currentCall,也要处理(关闭小窗口等) |
|
|
|
if (callStatus == 'cancelled' || callStatus == 'terminated') { |
|
|
|
final callSession = currentCall.value; |
|
|
|
// 如果有 channelId,验证是否匹配当前通话(如果存在) |
|
|
|
if (callSession != null && channelId != null && channelId.isNotEmpty && _callChannelId != channelId) { |
|
|
|
print( |
|
|
|
'⚠️ [CallController] channelId不匹配,忽略callStatus变化: 当前=$_callChannelId, 消息=$channelId', |
|
|
|
); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 处理取消/终止状态(即使没有 callSession 也要关闭小窗口) |
|
|
|
print( |
|
|
|
'📞 [CallController] 通话被取消/终止,callStatus=$callStatus, hasCallSession=${callSession != null}', |
|
|
|
); |
|
|
|
|
|
|
|
// 关闭视频通话邀请弹框(如果正在显示) |
|
|
|
SmartDialog.dismiss(); |
|
|
|
print('✅ [CallController] 已关闭视频通话邀请弹框'); |
|
|
|
|
|
|
|
// 取消超时计时器 |
|
|
|
_stopCallTimeoutTimer(); |
|
|
|
|
|
|
|
// 停止播放来电铃声 |
|
|
|
stopCallAudio(); |
|
|
|
|
|
|
|
// 停止通话计时器 |
|
|
|
_stopCallTimer(); |
|
|
|
|
|
|
|
// 离开RTC频道 |
|
|
|
await RTCManager.instance.leaveChannel(); |
|
|
|
|
|
|
|
// 如果有通话会话,结束通话 |
|
|
|
if (callSession != null) { |
|
|
|
await endCall(callDuration: callDuration ?? callDurationSeconds.value); |
|
|
|
} |
|
|
|
|
|
|
|
// 关闭通话小窗口 |
|
|
|
if (Get.isRegistered<OverlayController>()) { |
|
|
|
final overlayController = Get.find<OverlayController>(); |
|
|
|
overlayController.hideVideoCall(); |
|
|
|
print('✅ [CallController] 已关闭通话小窗口'); |
|
|
|
} |
|
|
|
|
|
|
|
// 退出 VideoCallPage(如果当前在 VideoCallPage) |
|
|
|
if (Get.currentRoute.contains('VideoCallPage')) { |
|
|
|
Get.back(); |
|
|
|
print('✅ [CallController] 已退出 VideoCallPage'); |
|
|
|
} |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 对于其他状态,需要检查是否有进行中的通话 |
|
|
|
final callSession = currentCall.value; |
|
|
|
if (callSession == null) { |
|
|
|
print('⚠️ [CallController] 当前没有进行中的通话,忽略callStatus变化'); |
|
|
|
@ -898,44 +952,8 @@ class CallController extends GetxController { |
|
|
|
// 结束通话 |
|
|
|
await endCall(callDuration: callDurationSeconds.value); |
|
|
|
} |
|
|
|
} else if (callStatus == 'cancelled' || callStatus == 'terminated') { |
|
|
|
// 通话被取消或终止 |
|
|
|
print( |
|
|
|
'📞 [CallController] 通话被取消/终止,callStatus=$callStatus, isInitiator=${callSession.isInitiator}', |
|
|
|
); |
|
|
|
|
|
|
|
// 关闭视频通话邀请弹框(如果正在显示) |
|
|
|
SmartDialog.dismiss(); |
|
|
|
print('✅ [CallController] 已关闭视频通话邀请弹框'); |
|
|
|
|
|
|
|
// 取消超时计时器 |
|
|
|
_stopCallTimeoutTimer(); |
|
|
|
|
|
|
|
// 停止播放来电铃声 |
|
|
|
stopCallAudio(); |
|
|
|
|
|
|
|
// 停止通话计时器 |
|
|
|
_stopCallTimer(); |
|
|
|
|
|
|
|
// 离开RTC频道 |
|
|
|
await RTCManager.instance.leaveChannel(); |
|
|
|
|
|
|
|
// 结束通话 |
|
|
|
await endCall(callDuration: callDuration ?? callDurationSeconds.value); |
|
|
|
|
|
|
|
// 关闭通话小窗口 |
|
|
|
if (Get.isRegistered<OverlayController>()) { |
|
|
|
final overlayController = Get.find<OverlayController>(); |
|
|
|
overlayController.hideVideoCall(); |
|
|
|
print('✅ [CallController] 已关闭通话小窗口'); |
|
|
|
} |
|
|
|
|
|
|
|
// 退出 VideoCallPage(如果当前在 VideoCallPage) |
|
|
|
if (Get.currentRoute.contains('VideoCallPage')) { |
|
|
|
Get.back(); |
|
|
|
print('✅ [CallController] 已退出 VideoCallPage'); |
|
|
|
} |
|
|
|
} |
|
|
|
// 注意:cancelled 和 terminated 状态已在方法开头处理,这里不再重复处理 |
|
|
|
} catch (e) { |
|
|
|
print('❌ [CallController] 处理callStatus变化失败: $e'); |
|
|
|
} |
|
|
|
|