|
|
|
@ -2,6 +2,7 @@ import 'dart:convert'; |
|
|
|
|
|
|
|
import 'package:agora_rtc_engine/agora_rtc_engine.dart'; |
|
|
|
import 'package:dating_touchme_app/controller/global.dart'; |
|
|
|
import 'package:dating_touchme_app/controller/overlay_controller.dart'; |
|
|
|
import 'package:dating_touchme_app/model/live/gift_product_model.dart'; |
|
|
|
import 'package:dating_touchme_app/model/rtc/link_mic_card_model.dart'; |
|
|
|
import 'package:dating_touchme_app/model/rtc/rtc_channel_data.dart'; |
|
|
|
@ -16,8 +17,8 @@ import 'package:get/get.dart'; |
|
|
|
import 'package:permission_handler/permission_handler.dart'; |
|
|
|
|
|
|
|
import '../../model/live/live_chat_message.dart'; |
|
|
|
import '../../pages/discover/live_end_page.dart'; |
|
|
|
import '../../pages/mine/real_name_page.dart'; |
|
|
|
import '../../pages/setting/match_league_page.dart'; |
|
|
|
import '../../pages/setting/match_spread_page.dart'; |
|
|
|
import 'svga_player_manager.dart'; |
|
|
|
|
|
|
|
@ -556,14 +557,26 @@ class RoomController extends GetxController with WidgetsBindingObserver { |
|
|
|
final operatorName = message['operatorName']?.toString() ?? '主持人'; |
|
|
|
|
|
|
|
print('✅ 收到踢人消息: 被踢用户ID $kickingUId'); |
|
|
|
|
|
|
|
|
|
|
|
// 判断当前用户是否是被踢的用户 |
|
|
|
if (rtcChannel.value?.uid == kickingUId) { |
|
|
|
// 被踢用户:关闭小窗口 |
|
|
|
if (Get.isRegistered<OverlayController>()) { |
|
|
|
try { |
|
|
|
final overlayController = Get.find<OverlayController>(); |
|
|
|
overlayController.hide(); // 隐藏直播房间小窗 |
|
|
|
} catch (e) { |
|
|
|
print('关闭小窗口失败: $e'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 被踢用户:离开房间 |
|
|
|
SmartDialog.showToast('您已被$operatorName踢出房间'); |
|
|
|
await leaveChannel(); |
|
|
|
// 可以选择自动返回上一页或跳转到其他页面 |
|
|
|
Get.back(); |
|
|
|
|
|
|
|
// 跳转到结束直播页面,并传入被踢出标识 |
|
|
|
Get.off( |
|
|
|
() => LiveEndPage(isKickedOut: true, operatorName: operatorName), |
|
|
|
); |
|
|
|
} else { |
|
|
|
// 其他用户:刷新房间详情 |
|
|
|
final channelName = RTCManager.instance.currentChannelId; |
|
|
|
@ -596,10 +609,7 @@ class RoomController extends GetxController with WidgetsBindingObserver { |
|
|
|
required int kickingUId, |
|
|
|
}) async { |
|
|
|
try { |
|
|
|
final requestData = { |
|
|
|
'channelId': channelId, |
|
|
|
'kickingUId': kickingUId, |
|
|
|
}; |
|
|
|
final requestData = {'channelId': channelId, 'kickingUId': kickingUId}; |
|
|
|
|
|
|
|
final response = await _networkService.rtcApi.kickingRtcChannelUser( |
|
|
|
requestData, |
|
|
|
@ -607,7 +617,7 @@ class RoomController extends GetxController with WidgetsBindingObserver { |
|
|
|
|
|
|
|
if (response.data.isSuccess) { |
|
|
|
SmartDialog.showToast('已踢出用户'); |
|
|
|
|
|
|
|
|
|
|
|
// 发送 RTM 消息通知所有用户 |
|
|
|
final channelName = RTCManager.instance.currentChannelId; |
|
|
|
if (channelName != null && channelName.isNotEmpty) { |
|
|
|
@ -617,19 +627,19 @@ class RoomController extends GetxController with WidgetsBindingObserver { |
|
|
|
'operatorId': GlobalData().userData?.id ?? '', |
|
|
|
'operatorName': GlobalData().userData?.nickName ?? '', |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
await RTMManager.instance.publishChannelMessage( |
|
|
|
channelName: channelName, |
|
|
|
message: json.encode(messageData), |
|
|
|
); |
|
|
|
print('✅ 踢人消息已发送: 踢出用户ID $kickingUId'); |
|
|
|
|
|
|
|
|
|
|
|
// 刷新频道详情 |
|
|
|
await fetchRtcChannelDetail(channelName); |
|
|
|
} |
|
|
|
} else { |
|
|
|
final message = response.data.message.isNotEmpty |
|
|
|
? response.data.message |
|
|
|
final message = response.data.message.isNotEmpty |
|
|
|
? response.data.message |
|
|
|
: '踢出用户失败'; |
|
|
|
SmartDialog.showToast(message); |
|
|
|
} |
|
|
|
@ -646,7 +656,9 @@ class RoomController extends GetxController with WidgetsBindingObserver { |
|
|
|
final base = response.data; |
|
|
|
if (base.isSuccess && base.data != null) { |
|
|
|
linkMicCard.value = base.data; |
|
|
|
print('✅ 获取连麦卡片成功: type=${base.data!.type}, num=${base.data!.num}, unitSellingPrice=${base.data!.unitSellingPrice}'); |
|
|
|
print( |
|
|
|
'✅ 获取连麦卡片成功: type=${base.data!.type}, num=${base.data!.num}, unitSellingPrice=${base.data!.unitSellingPrice}', |
|
|
|
); |
|
|
|
} else { |
|
|
|
linkMicCard.value = null; |
|
|
|
print('❌ 获取连麦卡片失败: ${base.message}'); |
|
|
|
|