全员结束会议、被移除提示时间延迟
This commit is contained in:
parent
fc9f72b88e
commit
85a475b19b
|
|
@ -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) {
|
||||
// 和服务器失去连接后,再延迟15秒(和signalR 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();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue