|
|
|
@ -1859,6 +1859,48 @@ class IMManager { |
|
|
|
// 只处理视频通话且状态为 missed 或 calling 的消息(新邀请) |
|
|
|
if ((callType == 'video' || callType == 'voice') && |
|
|
|
(callStatus == 'waitCalling' || callStatus == 'calling')) { |
|
|
|
// 检查当前是否正在通话中,如果是则自动拒绝新通话 |
|
|
|
final callController = CallController.instance; |
|
|
|
if (callController.currentCall.value != null) { |
|
|
|
// 当前正在通话中,自动拒绝新通话 |
|
|
|
if (Get.isLogEnable) { |
|
|
|
Get.log('📞 [IMManager] 当前正在通话中,自动拒绝新通话邀请: $fromId'); |
|
|
|
} else { |
|
|
|
print('📞 [IMManager] 当前正在通话中,自动拒绝新通话邀请: $fromId'); |
|
|
|
} |
|
|
|
|
|
|
|
// 自动拒绝新通话 |
|
|
|
Future.microtask(() async { |
|
|
|
try { |
|
|
|
ChatController? chatController; |
|
|
|
try { |
|
|
|
final tag = 'chat_$fromId'; |
|
|
|
if (Get.isRegistered<ChatController>(tag: tag)) { |
|
|
|
chatController = Get.find<ChatController>(tag: tag); |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
// 忽略错误,chatController 可以为 null |
|
|
|
} |
|
|
|
|
|
|
|
await callController.rejectCall( |
|
|
|
message: message, |
|
|
|
chatController: chatController, |
|
|
|
); |
|
|
|
|
|
|
|
if (Get.isLogEnable) { |
|
|
|
Get.log('✅ [IMManager] 已自动拒绝新通话邀请'); |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
if (Get.isLogEnable) { |
|
|
|
Get.log('⚠️ [IMManager] 自动拒绝新通话失败: $e'); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 不显示通话邀请弹框,直接返回 |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
RTMManager.instance.subscribe(channelId ?? ''); |
|
|
|
// 获取用户信息 |
|
|
|
Map<String, dynamic>? attributes; |
|
|
|
@ -1903,7 +1945,6 @@ class IMManager { |
|
|
|
final finalAvatarUrl = avatarUrl ?? ''; |
|
|
|
|
|
|
|
// 接收方收到视频通话时,开始播放来电铃声 |
|
|
|
final callController = CallController.instance; |
|
|
|
callController.startCallAudio(); |
|
|
|
|
|
|
|
// 显示视频通话邀请弹框 |
|
|
|
|