全员结束会议、被移除提示时间延迟

This commit is contained in:
fuenmao 2024-12-26 16:07:32 +08:00
parent fc9f72b88e
commit 85a475b19b
3 changed files with 188 additions and 156 deletions

View File

@ -54,7 +54,6 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
state.meetingToken.value = res.data!;
if (isInit == true) {
initRtc();
signalRSocket();
}
}
@ -64,7 +63,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
/// 2.
Future<void> mergeFetch(bool isAgain) async {
try {
if(isAgain == false){
if (isAgain == false) {
ToastUtils.showLoading();
}
@ -105,6 +104,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
void getMeetingRoomAllUser(List<MeetingRoomUser> meetingRoomUsers) async {
state.users.value = meetingRoomUsers;
state.cacheUsers.value = meetingRoomUsers;
update();
doHttpGetTvAnchor();
}
@ -328,7 +328,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
//
state.hubConnection.value?.onreconnecting((error) {
debugPrint("wgs输出===SignalR Socket-重连$error");
if(EasyLoading.isShow == false) {
if (EasyLoading.isShow == false) {
ToastUtils.showLoadingToMask("网络故障,正在重连...", EasyLoadingMaskType.black);
}
});
@ -338,24 +338,25 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
debugPrint("wgs输出===SignalR Socket-重连成功$connectionId");
joinMeetingToSocket(true);
ToastUtils.dismiss();
if(EasyLoading.isShow == false) {
if (EasyLoading.isShow == false) {
ToastUtils.showSuccessToMask("重连成功!", EasyLoadingMaskType.black);
}
});
// 5
state.hubConnection.value?.onclose((error){
state.hubConnection.value?.onclose((error) {
debugPrint("wgs输出===SignalR Socket-重连失败$error");
ToastUtils.dismiss();
if(state.isNormaExit.value == false && state.isShowOkAlertDialog.value == false){
if (state.isNormaExit.value == false &&
state.isShowOkAlertDialog.value == false) {
showOkAlertDialog(
context: Get.context!,
title: "提示",
message: "网络错误,请重新加入会议室",
okLabel: "确定",
barrierDismissible: false,
).then((OkCancelResult value){
).then((OkCancelResult value) {
Get.back();
Get.back();
});
@ -428,6 +429,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
debugPrint("wgs输出===Socket-关闭发言权限:观众");
}
}
update();
});
/// ------------------------------------------------------------------------------
@ -443,6 +445,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
}
state.users.value = state.cacheUsers.value;
state.isOpenMicrophone.value = e?[0];
update();
});
///
@ -480,6 +483,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
muteLocalAudioStream(true);
}
}
update();
});
/// ------------------------------------------------------------------------------
@ -493,6 +497,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
.toList();
state.cacheUsers.value.addAll(meetingRoomUsers);
state.users.value = state.cacheUsers.value;
update();
debugPrint("wgs输出===Socket-远端用户或主播加入会议室:$jsonStr");
});
@ -509,6 +514,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
}
}
state.users.value = state.cacheUsers.value;
update();
doHttpGetTvAnchor();
debugPrint("wgs输出===Socket-远端用户或主播离开会议室:$jsonStr");
});
@ -518,15 +524,21 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
// var jsonStr = const Utf8Decoder().convert(json.encode(e).runes.toList());
var jsonStr = json.encode(e);
debugPrint("wgs输出===Socket-被移除会议:$jsonStr");
Get.back();
state.isNormaExit.value = true;
ToastUtils.showSuccess("你已被移除会议");
Future.delayed(const Duration(seconds: 1), () {
Get.back();
});
});
///
state.hubConnection.value?.on("AllLeave", (e) {
debugPrint("wgs输出===Socket-全员结束会议");
Get.back();
state.isNormaExit.value = true;
ToastUtils.showSuccess("会议已结束");
Future.delayed(const Duration(seconds: 1), () {
Get.back();
});
});
/// ------------------------------------------------------------------------------
@ -607,6 +619,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
}
}
}
update();
});
///
@ -620,10 +633,15 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
}
///
/// isAgain
Future<void> joinMeetingToSocket(bool isAgain) async {
await state.hubConnection.value?.invoke("joinChannel",
args: [state.roomNumber.value, false, false, false]);
mergeFetch(isAgain);
if(isAgain == false){
initRtc(false);
}else{
mergeFetch(true);
}
}
///
@ -654,7 +672,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
/// ------------------------------------------------------------------------------SDK相关
/// SDK
Future<void> initRtc() async {
Future<void> initRtc(bool isAgain) async {
//
PermissionService.requestPermissions();
@ -687,6 +705,8 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
RtcEngineEventHandler(
//
onJoinChannelSuccess: (RtcConnection connection, int elapsed) {
state.isJoinSuccess.value = true;
mergeFetch(isAgain);
debugPrint("wgs输出===RTC-自己加入会议室ID${connection.localUid}");
},
@ -712,6 +732,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
}
}
}
update();
debugPrint("wgs输出===RTC-远端用户或主播离开会议室用户或主机的ID$remoteUid");
},
@ -813,32 +834,37 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
//
onConnectionStateChanged: (RtcConnection connection,
ConnectionStateType stateType, ConnectionChangedReasonType reason) {
ConnectionStateType stateType,
ConnectionChangedReasonType reason) {
debugPrint("wgs输出===RTC-网络连接状态发生改变:"
"会议室编号(${connection.channelId}"
"网络状态($stateType-${AgoraUtil.getConnectionStateChangedType(stateType)}"
"网络改变原因($reason-${AgoraUtil.getConnectionChangedReasonType(reason)}");
if(stateType == ConnectionStateType.connectionStateReconnecting){
if(EasyLoading.isShow == false){
ToastUtils.showLoadingToMask("网络故障,正在重连...", EasyLoadingMaskType.black);
if (stateType == ConnectionStateType.connectionStateReconnecting) {
if (EasyLoading.isShow == false) {
ToastUtils.showLoadingToMask(
"网络故障,正在重连...", EasyLoadingMaskType.black);
}
}else if(stateType == ConnectionStateType.connectionStateConnected && reason == ConnectionChangedReasonType.connectionChangedRejoinSuccess){
} else if (stateType == ConnectionStateType.connectionStateConnected &&
reason ==
ConnectionChangedReasonType.connectionChangedRejoinSuccess) {
ToastUtils.dismiss();
if(EasyLoading.isShow == false){
if (EasyLoading.isShow == false) {
ToastUtils.showSuccessToMask("重连成功!", EasyLoadingMaskType.black);
}
}else if(reason == ConnectionChangedReasonType.connectionChangedLost){
} else if (reason ==
ConnectionChangedReasonType.connectionChangedLost) {
// 15signalR Socket一致SDK继续重连
Future.delayed(const Duration(milliseconds: 15000), () {
ToastUtils.dismiss();
if(state.isShowOkAlertDialog.value == false){
if (state.isShowOkAlertDialog.value == false) {
showOkAlertDialog(
context: Get.context!,
title: "提示",
message: "网络错误,请重新加入会议室",
okLabel: "确定",
barrierDismissible: false,
).then((OkCancelResult value){
).then((OkCancelResult value) {
Get.back();
Get.back();
});

View File

@ -48,7 +48,7 @@ class MeetingMainState {
late Rx<MeetingRoomInfo?> meetingRoomInfo = Rx(null);
/// showOkAlertDialog
late RxBool isShowOkAlertDialog = false.obs;
/// 退退
/// 退退
late RxBool isNormaExit = false.obs;
///
@ -76,6 +76,8 @@ class MeetingMainState {
late RxBool isOpenShare = false.obs;
/// ID
late RxString remoteUid = "".obs;
///
late RxBool isJoinSuccess = false.obs;
///
late RxString spokesman = "".obs;

View File

@ -203,7 +203,7 @@ class MeetingMainPageState extends State<MeetingMainPage> {
// -
Visibility(
visible: state.pageState.value == 1,
child: null != state.rctEngine.value
child: state.isJoinSuccess.value == true && null != state.rctEngine.value && null != state.users.value && state.users.value.isNotEmpty
? Stack(
alignment: Alignment.center,
children: [
@ -275,7 +275,9 @@ class MeetingMainPageState extends State<MeetingMainPage> {
),
],
)
: Container()),
: Container(
child: Text('加载反馈:是否成功加入会议室${state.isJoinSuccess.value}-会议室对象${state.rctEngine.value}-成员列表${state.users.value.length}-全员观看ID${state.remoteUid.value}'),
)),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -1634,147 +1636,149 @@ class MeetingMainPageState extends State<MeetingMainPage> {
);
}));
/// gridview
pageList.add(Container(
color: ColorUtil.Color_57_57_57,
child: GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, childAspectRatio: 0.8, crossAxisSpacing: 0),
itemCount: state.cacheUsers.value.length,
itemBuilder: (BuildContext ctx, index) {
return Stack(
children: [
state.cacheUsers.value[index].enableCamera == true
? state.cacheUsers.value[index].uid ==
UserStore.to.userInfoEntity.value!.uid
? AgoraVideoView(
controller: VideoViewController(
rtcEngine: state.rctEngine.value!,
canvas: const VideoCanvas(
uid: 0,
setupMode:
VideoViewSetupMode.videoViewSetupAdd)),
/// gridview
pageList.add(GetBuilder<MeetingMainLogic>(builder: (controll){
return Container(
color: ColorUtil.Color_57_57_57,
child: GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, childAspectRatio: 0.8, crossAxisSpacing: 0),
itemCount: state.cacheUsers.value.length,
itemBuilder: (BuildContext ctx, index) {
return Stack(
children: [
state.cacheUsers.value[index].enableCamera == true
? state.cacheUsers.value[index].uid == UserStore.to.userInfoEntity.value!.uid
? AgoraVideoView(
controller: VideoViewController(
rtcEngine: state.rctEngine.value!,
canvas: const VideoCanvas(
uid: 0,
setupMode:
VideoViewSetupMode.videoViewSetupAdd)),
)
: AgoraVideoView(
controller: VideoViewController.remote(
rtcEngine: state.rctEngine.value!,
canvas: VideoCanvas(
uid: int.tryParse(
state.cacheUsers.value[index].uid),
setupMode:
VideoViewSetupMode.videoViewSetupAdd),
connection: RtcConnection(
channelId: state.roomNumber.value),
),
)
: Container(
color: ColorUtil.Color_16_19_13,
child: SizedBox(
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
'assets/images/metting_main_no_person.png',
width: 78.w,
height: 84.h,
),
const SizedBox(height: 12),
Text(
'该用户未开启摄像头...',
style: TextStyle(
color: ColorUtil.Color_255_255_255,
fontSize: 10.sp),
)
: AgoraVideoView(
controller: VideoViewController.remote(
rtcEngine: state.rctEngine.value!,
canvas: VideoCanvas(
uid: int.tryParse(
state.cacheUsers.value[index].uid),
setupMode:
VideoViewSetupMode.videoViewSetupAdd),
connection: RtcConnection(
channelId: state.roomNumber.value),
),
)
: Container(
color: ColorUtil.Color_16_19_13,
child: SizedBox(
width: double.infinity,
child: Column(
],
),
),
),
Positioned(
left: 4,
bottom: 4,
child: Row(
children: [
Visibility(
visible: state.cacheUsers.value[index].uid ==
UserStore.to.userInfoEntity.value!.uid,
child: Image.asset(
'assets/images/meeting_main_own.png',
width: 24.w,
height: 24.h,
),
),
Container(
height: 20,
margin: const EdgeInsets.only(left: 4),
padding: const EdgeInsets.only(left: 4, right: 4),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: ColorUtil.Color_0_0_0_96),
child: state.cacheUsers.value[index].enableMicr == true
? Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
width: 20.w,
height: 20.h,
child: LiquidCustomProgressIndicator(
value: state.cacheUsers.value[index]
.volume ??
0.0,
valueColor:
const AlwaysStoppedAnimation(
ColorUtil.Color_2_177_136),
backgroundColor:
ColorUtil.Color_255_255_255,
direction: Axis.vertical,
shapePath:
ViewSvgPath.getMicrpphonePath()),
),
SizedBox(
width: 70,
child: Text(
state.cacheUsers.value[index].userName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.sp,
color: ColorUtil.Color_255_255_255),
)
)
],
)
: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
'assets/images/metting_main_no_person.png',
width: 78.w,
height: 84.h,
'assets/images/meeting_main_microphone_open.png',
width: 20.w,
height: 20.h,
),
const SizedBox(height: 12),
Text(
'该用户未开启摄像头...',
style: TextStyle(
color: ColorUtil.Color_255_255_255,
fontSize: 10.sp),
SizedBox(
width: 70,
child: Text(
state.cacheUsers.value[index].userName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.sp,
color: ColorUtil.Color_255_255_255),
)
)
],
),
),
),
Positioned(
left: 4,
bottom: 4,
child: Row(
children: [
Visibility(
visible: state.cacheUsers.value[index].uid ==
UserStore.to.userInfoEntity.value!.uid,
child: Image.asset(
'assets/images/meeting_main_own.png',
width: 24.w,
height: 24.h,
),
),
Container(
height: 20,
margin: const EdgeInsets.only(left: 4),
padding: const EdgeInsets.only(left: 4, right: 4),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: ColorUtil.Color_0_0_0_96),
child: state.cacheUsers.value[index].enableMicr == true
? Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
width: 20.w,
height: 20.h,
child: LiquidCustomProgressIndicator(
value: state.cacheUsers.value[index]
.volume ??
0.0,
valueColor:
const AlwaysStoppedAnimation(
ColorUtil.Color_2_177_136),
backgroundColor:
ColorUtil.Color_255_255_255,
direction: Axis.vertical,
shapePath:
ViewSvgPath.getMicrpphonePath()),
),
SizedBox(
width: 70,
child: Text(
state.cacheUsers.value[index].userName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.sp,
color: ColorUtil.Color_255_255_255),
)
)
],
)
: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
'assets/images/meeting_main_microphone_open.png',
width: 20.w,
height: 20.h,
),
SizedBox(
width: 70,
child: Text(
state.cacheUsers.value[index].userName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.sp,
color: ColorUtil.Color_255_255_255),
)
)
],
),
)
],
),
)
],
);
}),
));
)
],
),
)
],
);
}),
);
}));
return pageList[position];
}
}