|
|
|
@ -264,7 +264,8 @@ class RoomController extends GetxController with WidgetsBindingObserver { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Future<void> _fetchRtcChannelDetail(String channelName) async { |
|
|
|
/// 获取 RTC 频道详情(公有方法,供外部调用) |
|
|
|
Future<void> fetchRtcChannelDetail(String channelName) async { |
|
|
|
try { |
|
|
|
final response = await _networkService.rtcApi.getRtcChannelDetail( |
|
|
|
channelName, |
|
|
|
@ -278,6 +279,10 @@ class RoomController extends GetxController with WidgetsBindingObserver { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Future<void> _fetchRtcChannelDetail(String channelName) async { |
|
|
|
await fetchRtcChannelDetail(channelName); |
|
|
|
} |
|
|
|
|
|
|
|
/// 发送公屏消息 |
|
|
|
Future<void> sendChatMessage(String content) async { |
|
|
|
final channelName = RTCManager.instance.currentChannelId; |
|
|
|
@ -453,88 +458,6 @@ class RoomController extends GetxController with WidgetsBindingObserver { |
|
|
|
} catch (e) { |
|
|
|
print('❌ 处理礼物消息失败: $e'); |
|
|
|
} |
|
|
|
} else if (message['type'] == 'join_chat') { |
|
|
|
final response = await _networkService.rtcApi |
|
|
|
.getDatingRtcChannelUserDetail( |
|
|
|
rtcChannel.value!.channelId, |
|
|
|
message['uid'], |
|
|
|
); |
|
|
|
if (!response.data.isSuccess) { |
|
|
|
return; |
|
|
|
} |
|
|
|
final currentDetail = rtcChannelDetail.value; |
|
|
|
if (currentDetail == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
final userData = response.data.data; |
|
|
|
if (userData == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (message['role'] == 'male_audience') { |
|
|
|
final maleInfo = RtcSeatUserInfo( |
|
|
|
miId: userData.miId, |
|
|
|
userId: userData.userId, |
|
|
|
nickName: userData.nickName, |
|
|
|
profilePhoto: userData.profilePhoto, |
|
|
|
genderCode: userData.genderCode, |
|
|
|
seatNumber: userData.seatNumber, |
|
|
|
isFriend: userData.isFriend, |
|
|
|
isMicrophoneOn: userData.isMicrophoneOn, |
|
|
|
isVideoOn: userData.isVideoOn, |
|
|
|
uid: message['uid'] is int |
|
|
|
? message['uid'] as int |
|
|
|
: int.tryParse(message['uid']?.toString() ?? ''), |
|
|
|
); |
|
|
|
final newDetail = RtcChannelDetail( |
|
|
|
channelId: currentDetail.channelId, |
|
|
|
anchorInfo: currentDetail.anchorInfo, |
|
|
|
maleInfo: maleInfo, |
|
|
|
femaleInfo: currentDetail.femaleInfo, |
|
|
|
); |
|
|
|
rtcChannelDetail.value = newDetail; |
|
|
|
} else if (message['role'] == 'female_audience') { |
|
|
|
final femaleInfo = RtcSeatUserInfo( |
|
|
|
miId: userData.miId, |
|
|
|
userId: userData.userId, |
|
|
|
nickName: userData.nickName, |
|
|
|
profilePhoto: userData.profilePhoto, |
|
|
|
genderCode: userData.genderCode, |
|
|
|
seatNumber: userData.seatNumber, |
|
|
|
isFriend: userData.isFriend, |
|
|
|
isMicrophoneOn: userData.isMicrophoneOn, |
|
|
|
isVideoOn: userData.isVideoOn, |
|
|
|
uid: message['uid'] is int |
|
|
|
? message['uid'] as int |
|
|
|
: int.tryParse(message['uid']?.toString() ?? ''), |
|
|
|
); |
|
|
|
final newDetail = RtcChannelDetail( |
|
|
|
channelId: currentDetail.channelId, |
|
|
|
anchorInfo: currentDetail.anchorInfo, |
|
|
|
maleInfo: currentDetail.maleInfo, |
|
|
|
femaleInfo: femaleInfo, |
|
|
|
); |
|
|
|
rtcChannelDetail.value = newDetail; |
|
|
|
} |
|
|
|
// } |
|
|
|
} else if (message['type'] == 'leave_chat') { |
|
|
|
if (message['role'] == 'male_audience') { |
|
|
|
final newDetail = RtcChannelDetail( |
|
|
|
channelId: rtcChannelDetail.value!.channelId, |
|
|
|
anchorInfo: rtcChannelDetail.value!.anchorInfo, |
|
|
|
maleInfo: null, |
|
|
|
femaleInfo: rtcChannelDetail.value!.femaleInfo, |
|
|
|
); |
|
|
|
rtcChannelDetail.value = newDetail; |
|
|
|
} else if (message['role'] == 'female_audience') { |
|
|
|
final newDetail = RtcChannelDetail( |
|
|
|
channelId: rtcChannelDetail.value!.channelId, |
|
|
|
anchorInfo: rtcChannelDetail.value!.anchorInfo, |
|
|
|
maleInfo: rtcChannelDetail.value!.maleInfo, |
|
|
|
femaleInfo: null, |
|
|
|
); |
|
|
|
rtcChannelDetail.value = newDetail; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|