diff --git a/lib/rtc/rtc_manager.dart b/lib/rtc/rtc_manager.dart index b6091e4..0e51098 100644 --- a/lib/rtc/rtc_manager.dart +++ b/lib/rtc/rtc_manager.dart @@ -9,6 +9,7 @@ import 'package:get/get.dart'; import '../controller/discover/room_controller.dart'; import '../controller/message/call_controller.dart'; import '../pages/discover/live_room_page.dart'; +import '../service/live_chat_message_service.dart'; enum RTCType { call, // 通话(语音/视频通话) @@ -208,6 +209,11 @@ class RTCManager { channelId != null && channelId.isNotEmpty) { final roomController = Get.find(); + if(remoteUid == roomController.rtcChannelDetail.value?.anchorInfo?.uid){ + await roomController.leaveChannel(); + // 调用 LiveChatMessageService 处理结束直播消息 + LiveChatMessageService.instance.handleEndLiveMessage(); + } await roomController.fetchRtcChannelDetail(channelId); } } diff --git a/lib/service/live_chat_message_service.dart b/lib/service/live_chat_message_service.dart index 4267e71..f0d4b73 100644 --- a/lib/service/live_chat_message_service.dart +++ b/lib/service/live_chat_message_service.dart @@ -72,7 +72,7 @@ class LiveChatMessageService { if (messageData['type'] == 'end_live') { RoomController controller = Get.find(); await controller.leaveChannel(); - _handleEndLiveMessage(); + handleEndLiveMessage(); return; } @@ -119,7 +119,7 @@ class LiveChatMessageService { } /// 处理结束直播消息 - void _handleEndLiveMessage() { + void handleEndLiveMessage() { try { // 检查 overlay 是否显示,如果显示则关闭 if (Get.isRegistered()) {