1.7下午

This commit is contained in:
fuenmao 2025-01-07 15:45:20 +08:00
parent 976b76adae
commit 44180f9924
9 changed files with 237 additions and 184 deletions

View File

@ -5,7 +5,7 @@ class RequestConfig {
// static const _devBaseUrl = "https://zyapitest.23544.com:16440"; // // static const _devBaseUrl = "https://zyapitest.23544.com:16440"; //
static const _devBaseUrl = "http://192.168.2.9:5192"; // static const _devBaseUrl = "http://192.168.2.9:5192"; //
// static const _proBaseUrl = "http://192.168.2.119:1091"; // // static const _proBaseUrl = "http://192.168.2.119:1091"; //
static const _proBaseUrl = "https://zyapi.23544.com/ipadapi"; // static const _proBaseUrl = "http://192.168.2.9:5192"; //
static const imgUrl = 'https://dpc-job-oss.23544.com/'; static const imgUrl = 'https://dpc-job-oss.23544.com/';
static RequestConfig? _instance; static RequestConfig? _instance;

View File

@ -6,6 +6,8 @@ import 'package:dio/dio.dart';
import 'package:wgshare/common/api/retrofit_client.dart'; import 'package:wgshare/common/api/retrofit_client.dart';
import 'package:wgshare/common/config/request_config.dart'; import 'package:wgshare/common/config/request_config.dart';
import 'package:wgshare/common/store/user_store.dart'; import 'package:wgshare/common/store/user_store.dart';
import 'package:wgshare/utils/anti_shake_throttling.dart';
import 'package:wgshare/utils/routeUtil.dart';
import 'package:wgshare/utils/storage.dart'; import 'package:wgshare/utils/storage.dart';
import 'package:wgshare/utils/toast_utils.dart'; import 'package:wgshare/utils/toast_utils.dart';
import 'package:wgshare/routes/app_routes.dart'; import 'package:wgshare/routes/app_routes.dart';
@ -111,9 +113,9 @@ class ResponseHandle extends Interceptor {
((data['code'] != null && (data['code'] == 401 || data['code'] == '401')) || ((data['code'] != null && (data['code'] == 401 || data['code'] == '401')) ||
(data['Code'] != null && (data['Code'] == 401 || data['Code'] == '401'))); (data['Code'] != null && (data['Code'] == 401 || data['Code'] == '401')));
if (statusCode == 401 || flag) { if ((statusCode == 401 || flag) && RouteUtil.getRoute() != Routes.loginPage) {
Future.delayed(const Duration(seconds: 2), () { easyThrottle("toLogin",(){
StorageService.to.erase(); UserStore.to.erase();
getx.Get.offAllNamed(Routes.loginPage); getx.Get.offAllNamed(Routes.loginPage);
}); });
} }
@ -163,12 +165,12 @@ class TheError extends Interceptor {
switch (statusCode) { switch (statusCode) {
case 401: case 401:
message = '用户登录失效,请重新登录'; message = '用户登录失效,请重新登录';
if(RouteUtil.getRoute() != Routes.loginPage){
Future.delayed(const Duration(seconds: 2), () { easyThrottle("toLogin",(){
// UserStore.to.erase(); UserStore.to.erase();
StorageService.to.erase(); getx.Get.offAllNamed(Routes.loginPage);
getx.Get.offAllNamed(Routes.loginPage); });
}); }
break; break;
case 404: case 404:
message = '无效地址'; message = '无效地址';

View File

@ -134,6 +134,7 @@ class HomeLogic extends GetxController with RequestToolMixin {
leftBtnStr: '拒绝', leftBtnStr: '拒绝',
rightBtnStr: '同意', rightBtnStr: '同意',
leftBtnCallback: () { leftBtnCallback: () {
Get.back();
Get.toNamed(Routes.meetingMainPage, Get.toNamed(Routes.meetingMainPage,
arguments: { arguments: {
"roomNumber": state.meetingRooms.value[index].roomNum "roomNumber": state.meetingRooms.value[index].roomNum
@ -142,6 +143,7 @@ class HomeLogic extends GetxController with RequestToolMixin {
rightBtnCallback: () { rightBtnCallback: () {
PermissionService.requestPermissions().then((value) { PermissionService.requestPermissions().then((value) {
if (value == true) { if (value == true) {
Get.back();
Get.toNamed(Routes.meetingMainPage, Get.toNamed(Routes.meetingMainPage,
arguments: { arguments: {
"roomNumber": state.meetingRooms.value[index].roomNum "roomNumber": state.meetingRooms.value[index].roomNum

View File

@ -20,22 +20,22 @@ import '../../view/upgrade/loadJson/load_network_json.dart';
import 'login_state.dart'; import 'login_state.dart';
class LoginLogic extends GetxController with RequestToolMixin { class LoginLogic extends GetxController with RequestToolMixin {
final LoginState state = LoginState(); late LoginState state;
@override @override
void onInit() { void onInit() {
super.onInit(); print("初始化登录init................");
state = LoginState();
HideCheckVersion hideCheckVersion = HideCheckVersion(); HideCheckVersion hideCheckVersion = HideCheckVersion();
hideCheckVersion.doHttpHideCheckVersion(); hideCheckVersion.doHttpHideCheckVersion();
super.onInit();
} }
@override @override
void onClose() { void onClose() {
print("销毁onClose................");
super.onClose(); super.onClose();
state.passwordController.dispose();
state.userNameController.dispose();
state.meetingCodeController.dispose();
state.nickNameCodeController.dispose();
} }
/// ///
@ -50,24 +50,24 @@ class LoginLogic extends GetxController with RequestToolMixin {
/// ///
Future<void> doHttpLogin() async { Future<void> doHttpLogin() async {
if(state.userNameController.text.isEmpty){ if(state.userNameController!.text.isEmpty){
ToastUtils.showError("请输入账号"); ToastUtils.showError("请输入账号");
}else if(state.passwordController.text.isEmpty){ }else if(state.passwordController!.text.isEmpty){
ToastUtils.showError("请输入密码"); ToastUtils.showError("请输入密码");
}else if(state.checkAgreementBool.value != true){ }else if(state.checkAgreementBool.value != true){
ToastUtils.showError("请阅读并勾选相关协议"); ToastUtils.showError("请阅读并勾选相关协议");
}else{ }else{
BaseStructureResult<UserInfoEntity> res = await getClient().login(state.userNameController.text, md5.convert(utf8.encode(state.passwordController.text)).toString()); BaseStructureResult<UserInfoEntity> res = await getClient().login(state.userNameController!.text, md5.convert(utf8.encode(state.passwordController!.text)).toString());
if (null != res.data) { if (null != res.data) {
UserStore.to.setToken(res.data!.token); UserStore.to.setToken(res.data!.token);
UserStore.to.setRefreshToken(res.data!.refreshToken); UserStore.to.setRefreshToken(res.data!.refreshToken);
UserStore.to.setUserDetailInfo(res.data!); UserStore.to.setUserDetailInfo(res.data!);
UserStore.to.setLoginType(AppConfig.NORMAL_LOGIN); UserStore.to.setLoginType(AppConfig.NORMAL_LOGIN);
Get.offAllNamed(Routes.startPage); Get.offAllNamed(Routes.startPage);
state.userNameController.text = ""; state.userNameController!.text = "";
state.passwordController.text = ""; state.passwordController!.text = "";
state.meetingCodeController.text = ""; state.meetingCodeController!.text = "";
state.nickNameCodeController.text = ""; state.nickNameCodeController!.text = "";
state.checkAgreementBool.value = false; state.checkAgreementBool.value = false;
} }
} }
@ -75,26 +75,26 @@ class LoginLogic extends GetxController with RequestToolMixin {
/// ///
Future<void> doHttpAnonymousLogin() async { Future<void> doHttpAnonymousLogin() async {
if(state.meetingCodeController.text.isEmpty){ if(state.meetingCodeController!.text.isEmpty){
ToastUtils.showError("请输入会议号"); ToastUtils.showError("请输入会议号");
}else if(state.meetingCodeController.text.length != 8){ }else if(state.meetingCodeController!.text.length != 8){
ToastUtils.showError("请输入正确的会议号"); ToastUtils.showError("请输入正确的会议号");
}else if(state.nickNameCodeController.text.isEmpty){ }else if(state.nickNameCodeController!.text.isEmpty){
ToastUtils.showError("请输入昵称"); ToastUtils.showError("请输入昵称");
}else if(state.checkAgreementBool != true){ }else if(state.checkAgreementBool != true){
ToastUtils.showError("请阅读并勾选相关协议"); ToastUtils.showError("请阅读并勾选相关协议");
}else{ }else{
BaseStructureResult<UserInfoEntity> res = await getClient().anonLogin(await DeviceInfo.getDeviceId(),state.nickNameCodeController.text, state.meetingCodeController.text); BaseStructureResult<UserInfoEntity> res = await getClient().anonLogin(await DeviceInfo.getDeviceId(),state.nickNameCodeController!.text, state.meetingCodeController!.text);
if (null != res.data) { if (null != res.data) {
UserStore.to.setToken(res.data!.token); UserStore.to.setToken(res.data!.token);
UserStore.to.setRefreshToken(res.data!.refreshToken); UserStore.to.setRefreshToken(res.data!.refreshToken);
UserStore.to.setUserDetailInfo(res.data!); UserStore.to.setUserDetailInfo(res.data!);
UserStore.to.setLoginType(AppConfig.ANONYMOUS_LOGIN); UserStore.to.setLoginType(AppConfig.ANONYMOUS_LOGIN);
Get.toNamed(Routes.meetingMainPage, arguments: {"roomNumber": state.meetingCodeController.text}); Get.toNamed(Routes.meetingMainPage, arguments: {"roomNumber": state.meetingCodeController!.text});
state.userNameController.text = ""; state.userNameController!.text = "";
state.passwordController.text = ""; state.passwordController!.text = "";
state.meetingCodeController.text = ""; state.meetingCodeController!.text = "";
state.nickNameCodeController.text = ""; state.nickNameCodeController!.text = "";
state.checkAgreementBool.value = false; state.checkAgreementBool.value = false;
} }
} }
@ -102,16 +102,16 @@ class LoginLogic extends GetxController with RequestToolMixin {
/// ///
Future<void> doHttpCheckMeetingRoom() async { Future<void> doHttpCheckMeetingRoom() async {
if(state.meetingCodeController.text.isEmpty){ if(state.meetingCodeController!.text.isEmpty){
ToastUtils.showError("请输入会议号"); ToastUtils.showError("请输入会议号");
}else if(state.meetingCodeController.text.length != 8){ }else if(state.meetingCodeController!.text.length != 8){
ToastUtils.showError("请输入正确的会议号"); ToastUtils.showError("请输入正确的会议号");
}else if(state.nickNameCodeController.text.isEmpty){ }else if(state.nickNameCodeController!.text.isEmpty){
ToastUtils.showError("请输入昵称"); ToastUtils.showError("请输入昵称");
}else if(state.checkAgreementBool != true){ }else if(state.checkAgreementBool != true){
ToastUtils.showError("请阅读并勾选相关协议"); ToastUtils.showError("请阅读并勾选相关协议");
}else{ }else{
BaseStructureResult<bool> res = await getClient().checkout(state.meetingCodeController.text); BaseStructureResult<bool> res = await getClient().checkout(state.meetingCodeController!.text);
if (null != res.data) { if (null != res.data) {
if(res.data == true){ if(res.data == true){
doHttpAnonymousLogin(); doHttpAnonymousLogin();

View File

@ -3,12 +3,14 @@ import 'package:get/get.dart';
class LoginState { class LoginState {
LoginState() {} TextEditingController? userNameController;
TextEditingController? passwordController;
TextEditingController? meetingCodeController;
TextEditingController? nickNameCodeController;
LoginState() {
}
late TextEditingController userNameController = TextEditingController();
late TextEditingController passwordController = TextEditingController();
late TextEditingController meetingCodeController = TextEditingController();
late TextEditingController nickNameCodeController = TextEditingController();
/// 01 /// 01
late RxInt pageState = 0.obs; late RxInt pageState = 0.obs;

View File

@ -23,6 +23,10 @@ class _LoginPageState extends State<LoginPage> {
@override @override
void initState() { void initState() {
Utils.hideKeyboard(); Utils.hideKeyboard();
state.userNameController = TextEditingController();
state.passwordController = TextEditingController();
state.meetingCodeController = TextEditingController();
state.nickNameCodeController = TextEditingController();
super.initState(); super.initState();
} }
@ -394,4 +398,13 @@ class _LoginPageState extends State<LoginPage> {
), ),
); );
} }
@override
void dispose() {
state.passwordController?.dispose();
state.userNameController?.dispose();
state.meetingCodeController?.dispose();
state.nickNameCodeController?.dispose();
super.dispose();
}
} }

View File

@ -64,9 +64,9 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
await getClient().getMeetingToken(state.roomNumber.value); await getClient().getMeetingToken(state.roomNumber.value);
state.meetingToken.value = res.data!; state.meetingToken.value = res.data!;
if (isInit == true) { if (isInit) {
signalRSocket(); signalRSocket();
}else{ } else {
initRtc(); initRtc();
} }
} }
@ -89,6 +89,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
getMeetingRoomAllUser(results[1].data as List<MeetingRoomUser>); getMeetingRoomAllUser(results[1].data as List<MeetingRoomUser>);
} finally { } finally {
ToastUtils.dismiss(); ToastUtils.dismiss();
ToastUtils.showSuccess("${state.isJoinSuccess}--${state.rctEngine.value}--${state.users.isNotEmpty}");
} }
} }
@ -162,15 +163,17 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
} }
/// grid切换大屏 /// grid切换大屏
void checkLargeScreen(String uid){ void checkLargeScreen(String uid) {
ToastUtils.showSuccess("切换用户成功"); ToastUtils.showSuccess("切换用户成功");
if(uid == UserStore.to.userInfoEntity.value!.uid) { if (uid == UserStore.to.userInfoEntity.value!.uid) {
state.remoteUid.value = "0"; state.remoteUid.value = "0";
}else{ state.remoteAssistantUid.value = "0";
if(state.isSpeak.value == true && state.isOpenCamera.value == true){ } else {
if (state.isSpeak.value == true && state.isOpenCamera.value == true) {
state.floating.value?.open(Get.context!); state.floating.value?.open(Get.context!);
} }
state.remoteUid.value = uid; state.remoteUid.value = uid;
state.remoteAssistantUid.value = uid;
} }
changePageState(0); changePageState(0);
Future.delayed(const Duration(milliseconds: 200), () { Future.delayed(const Duration(milliseconds: 200), () {
@ -208,7 +211,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
/// ------------------------------------------------------------------------------ /// ------------------------------------------------------------------------------
/// ///
Future<void> doHttpSetMicr(bool isOpenMicrophone) async { Future<void> doHttpSetMicr(bool isOpenMicrophone) async {
if(isOpenMicrophone == false){ if (isOpenMicrophone == false) {
state.spokesman.value = ""; state.spokesman.value = "";
state.spokesmanVolume.value = 0; state.spokesmanVolume.value = 0;
} }
@ -257,9 +260,9 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
isOtherOpenCamera = true; isOtherOpenCamera = true;
} }
} }
if(isOtherOpenCamera == false){ if (isOtherOpenCamera == false) {
changePageState(0); changePageState(0);
}else{ } else {
state.remoteUid.value = ""; state.remoteUid.value = "";
changePageState(1); changePageState(1);
} }
@ -270,7 +273,8 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
// //
var isCurrentUserIsCamera = false; var isCurrentUserIsCamera = false;
for (var i = 0; i < state.cacheUsers.value.length; i++) { for (var i = 0; i < state.cacheUsers.value.length; i++) {
if (state.remoteUid.value == state.cacheUsers.value[i].uid && state.cacheUsers.value[i].enableCamera == true) { if (state.remoteUid.value == state.cacheUsers.value[i].uid &&
state.cacheUsers.value[i].enableCamera == true) {
isCurrentUserIsCamera = true; isCurrentUserIsCamera = true;
} }
} }
@ -398,11 +402,21 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
debugPrint("wgs输出===SignalR Socket-重连失败$error"); debugPrint("wgs输出===SignalR Socket-重连失败$error");
ToastUtils.dismiss(); ToastUtils.dismiss();
if ((state.isNormaExit.value == false && state.isShowOkAlertDialog.value == false) || null == UserStore.to.userInfoEntity.value) { debugPrint(
"wgs输出===SignalR Socket-重连打印1${state.isNormaExit.value == false && state.isShowOkAlertDialog.value == false}");
debugPrint("wgs输出===SignalR Socket-重连打印2${null != UserStore.to.token}");
debugPrint(
"wgs输出===SignalR Socket-重连打印3${UserStore.to.token!.isNotEmpty}");
debugPrint(
"wgs输出===SignalR Socket-重连打印4${(state.isNormaExit.value == false && state.isShowOkAlertDialog.value == false) || null != UserStore.to.token || UserStore.to.token!.isNotEmpty}");
if ((state.isNormaExit.value == false &&
state.isShowOkAlertDialog.value == false) ||
(state.isNormaExit.value == false && null != UserStore.to.token)) {
showOkAlertDialog( showOkAlertDialog(
context: Get.context!, context: Get.context!,
title: "提示", title: "提示",
message: "网络错误,请重新加入会议室", message: "网络错误,请重新加入会议室1",
okLabel: "确定", okLabel: "确定",
barrierDismissible: false, barrierDismissible: false,
).then((OkCancelResult value) { ).then((OkCancelResult value) {
@ -426,7 +440,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
for (MeetingRoomUser mru in state.cacheUsers.value) { for (MeetingRoomUser mru in state.cacheUsers.value) {
if (mru.uid == meetingRoomUser.uid) { if (mru.uid == meetingRoomUser.uid) {
mru.roleId = meetingRoomUser.roleId; mru.roleId = meetingRoomUser.roleId;
if(state.defaulOpenState.value == 1){ if (state.defaulOpenState.value == 1) {
mru.enableMicr = true; mru.enableMicr = true;
} }
mru.isRoomManager = meetingRoomUser.isRoomManager; mru.isRoomManager = meetingRoomUser.isRoomManager;
@ -571,7 +585,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
} }
state.users.value = state.cacheUsers.value; state.users.value = state.cacheUsers.value;
update(); update();
if(listDynamic[0] != UserStore.to.userInfoEntity.value!.uid){ if (listDynamic[0] != UserStore.to.userInfoEntity.value!.uid) {
doHttpGetTvAnchor(); doHttpGetTvAnchor();
} }
debugPrint("wgs输出===Socket-远端用户或主播离开会议室:$jsonStr"); debugPrint("wgs输出===Socket-远端用户或主播离开会议室:$jsonStr");
@ -648,8 +662,9 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
if (mru.uid == meetingRoomUser.uid) { if (mru.uid == meetingRoomUser.uid) {
mru.enableCamera = true; mru.enableCamera = true;
} }
debugPrint("wgs输出===Socket-用户单独开摄像头---${state.remoteUid.value}--${meetingRoomUser.uid}"); debugPrint(
if(state.remoteUid.value == meetingRoomUser.uid){ "wgs输出===Socket-用户单独开摄像头---${state.remoteUid.value}--${meetingRoomUser.uid}");
if (state.remoteUid.value == meetingRoomUser.uid) {
doHttpGetTvAnchor(); doHttpGetTvAnchor();
} }
} }
@ -687,14 +702,15 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
muteLocalVideoStream(true); muteLocalVideoStream(true);
// //
stopPreview(); stopPreview();
//
if (state.remoteUid.value == "0") {
state.remoteUid.value = "";
}
// //
if (state.floating.value?.isShowing == true) { if (state.floating.value?.isShowing == true) {
state.floating.value?.close(); state.floating.value?.close();
} }
//
if (state.remoteUid.value == "0") {
state.remoteUid.value = "";
doHttpGetTvAnchor();
}
} }
} }
update(); update();
@ -713,8 +729,12 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
/// ///
/// isAgain /// isAgain
Future<void> joinMeetingToSocket(bool isAgain) async { Future<void> joinMeetingToSocket(bool isAgain) async {
await state.hubConnection.value?.invoke("joinChannel", await state.hubConnection.value?.invoke("joinChannel", args: [
args: [state.roomNumber.value, state.isOpenMicrophone.value, state.isOpenCamera.value, state.isSpeak.value]); state.roomNumber.value,
state.isOpenMicrophone.value,
state.isOpenCamera.value,
state.isSpeak.value
]);
mergeFetch(isAgain); mergeFetch(isAgain);
/*if(isAgain == false){ /*if(isAgain == false){
mergeFetch(isAgain); mergeFetch(isAgain);
@ -765,7 +785,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
// //
// //
enableVideo(); await enableVideo();
// //
await state.rctEngine.value?.setDefaultAudioRouteToSpeakerphone(false); await state.rctEngine.value?.setDefaultAudioRouteToSpeakerphone(false);
// //
@ -775,61 +795,59 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
await state.rctEngine.value await state.rctEngine.value
?.setDualStreamMode(mode: SimulcastStreamMode.enableSimulcastStream); ?.setDualStreamMode(mode: SimulcastStreamMode.enableSimulcastStream);
joinMeetingToRtc();
// //
state.rctEngine.value?.registerEventHandler( state.rctEngine.value?.registerEventHandler(
RtcEngineEventHandler( RtcEngineEventHandler(
// //
onJoinChannelSuccess: (RtcConnection connection, int elapsed) { onJoinChannelSuccess: (RtcConnection connection, int elapsed) {
state.isJoinSuccess.value = true; state.isJoinSuccess.value = true;
debugPrint("wgs输出===RTC-自己加入会议室ID${connection.localUid}"); debugPrint("wgs输出===RTC-自己加入会议室ID${connection.localUid}");
}, },
// //
onLeaveChannel: (RtcConnection connection, RtcStats stats) { onLeaveChannel: (RtcConnection connection, RtcStats stats) {
debugPrint("wgs输出===RTC-自己离开会议室ID${connection.localUid}"); debugPrint("wgs输出===RTC-自己离开会议室ID${connection.localUid}");
}, },
// - // -
onUserJoined: (RtcConnection connection, int remoteUid, int elapsed) { onUserJoined: (RtcConnection connection, int remoteUid, int elapsed) {
debugPrint("wgs输出===RTC-远端用户或主播加入会议室用户或主机的ID$remoteUid"); debugPrint("wgs输出===RTC-远端用户或主播加入会议室用户或主机的ID$remoteUid");
}, },
// - // -
onUserOffline: (RtcConnection connection, int remoteUid, onUserOffline: (RtcConnection connection, int remoteUid,
UserOfflineReasonType reason) async { UserOfflineReasonType reason) async {
// //
if (remoteUid.toString().length == 9) { if (remoteUid.toString().length == 9) {
for (var i = 0; i < state.cacheUsers.value.length; i++) { for (var i = 0; i < state.cacheUsers.value.length; i++) {
if (remoteUid.toString() == if (remoteUid.toString() ==
state.cacheUsers.value[i].screenShareId) { state.cacheUsers.value[i].screenShareId) {
state.cacheUsers.value[i].enableShare = false; state.cacheUsers.value[i].enableShare = false;
}
}
} }
} update();
} debugPrint("wgs输出===RTC-远端用户或主播离开会议室用户或主机的ID$remoteUid");
update(); },
debugPrint("wgs输出===RTC-远端用户或主播离开会议室用户或主机的ID$remoteUid");
},
// //
onAudioRoutingChanged: (int routing) { onAudioRoutingChanged: (int routing) {
debugPrint("wgs输出===RTC-音频路由切换:$routing"); debugPrint("wgs输出===RTC-音频路由切换:$routing");
state.communicationMode.value = routing; state.communicationMode.value = routing;
if (routing == 1) { if (routing == 1) {
debugPrint("wgs输出===RTC-音频路由切换为听筒"); debugPrint("wgs输出===RTC-音频路由切换为听筒");
} else if (routing == 3) { } else if (routing == 3) {
debugPrint("wgs输出===RTC-音频路由切换为扬声器"); debugPrint("wgs输出===RTC-音频路由切换为扬声器");
} else { } else {
debugPrint("wgs输出===RTC-音频路由切换为外接设备"); debugPrint("wgs输出===RTC-音频路由切换为外接设备");
} }
}, },
// //
onLocalAudioStateChanged: (RtcConnection connection, onLocalAudioStateChanged: (RtcConnection connection,
LocalAudioStreamState state, LocalAudioStreamReason reason) { LocalAudioStreamState state, LocalAudioStreamReason reason) {
debugPrint("wgs输出===RTC-音频采集开关:$state"); debugPrint("wgs输出===RTC-音频采集开关:$state");
}, },
// //
onRemoteVideoStateChanged: (RtcConnection connection, onRemoteVideoStateChanged: (RtcConnection connection,
@ -837,56 +855,55 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
RemoteVideoState remoteVideoState, RemoteVideoState remoteVideoState,
RemoteVideoStateReason remoteVideoStateReason, RemoteVideoStateReason remoteVideoStateReason,
int elapsed) { int elapsed) {
debugPrint( debugPrint(
"wgs输出===RTC-远端视频状态发生改变ID-$remoteUid-状态-$remoteVideoStateReason"); "wgs输出===RTC-远端视频状态发生改变ID-$remoteUid-状态-$remoteVideoStateReason");
if (remoteVideoStateReason == if (remoteVideoStateReason ==
RemoteVideoStateReason.remoteVideoStateReasonRemoteMuted) { RemoteVideoStateReason.remoteVideoStateReasonRemoteMuted) {
// //
if (remoteUid.toString().length != 9) { if (remoteUid.toString().length != 9) {
// //
if (remoteUid.toString() == state.remoteUid.value) { if (remoteUid.toString() == state.remoteUid.value) {
// //
doHttpGetTvAnchor(); doHttpGetTvAnchor();
}
} else {
//
}
} }
} else { },
//
}
}
},
// //
onAudioVolumeIndication: (RtcConnection connection, onAudioVolumeIndication: (RtcConnection connection,
List<AudioVolumeInfo> speakers, List<AudioVolumeInfo> speakers,
int speakerNumber, int speakerNumber,
int totalVolume) { int totalVolume) {
if (speakers.isNotEmpty) { if (speakers.isNotEmpty) {
for (AudioVolumeInfo avi in speakers) {
for (AudioVolumeInfo avi in speakers) { if (avi.uid == 0) {
if(avi.uid == 0){ // debugPrint("wgs输出===RTC-本地用户音量提示:${avi.uid}--${avi.volume}");
debugPrint("wgs输出===RTC-本地用户音量提示:${avi.uid}--${avi.volume}"); for (MeetingRoomUser mru in state.cacheUsers.value) {
for(MeetingRoomUser mru in state.cacheUsers.value){ if (UserStore.to.userInfoEntity.value!.uid == mru.uid) {
if(UserStore.to.userInfoEntity.value!.uid == mru.uid){ mru.volume = CountMicrophoneVolume.getVolume(avi.volume!);
mru.volume = CountMicrophoneVolume.getVolume(avi.volume!); state.microphoneVolume.value =
state.microphoneVolume.value = CountMicrophoneVolume.getVolume(avi.volume!);
CountMicrophoneVolume.getVolume(avi.volume!); }
} }
}
}else{
debugPrint("wgs输出===RTC-远端用户音量提示:${avi.uid}--${avi.volume}");
for(MeetingRoomUser mru in state.cacheUsers.value){
mru.volume = CountMicrophoneVolume.getVolume(avi.volume!);
if (avi.volume != 0) {
state.spokesman.value = mru.userName;
state.spokesmanVolume.value =
CountMicrophoneVolume.getVolume(avi.volume!);
} else { } else {
state.spokesman.value = ""; // debugPrint("wgs输出===RTC-远端用户音量提示:${avi.uid}--${avi.volume}");
state.spokesmanVolume.value = 0; for (MeetingRoomUser mru in state.cacheUsers.value) {
mru.volume = CountMicrophoneVolume.getVolume(avi.volume!);
if (avi.volume != 0) {
state.spokesman.value = mru.userName;
state.spokesmanVolume.value =
CountMicrophoneVolume.getVolume(avi.volume!);
} else {
state.spokesman.value = "";
state.spokesmanVolume.value = 0;
}
}
} }
} /*for (MeetingRoomUser mru in state.cacheUsers.value) {
}
/*for (MeetingRoomUser mru in state.cacheUsers.value) {
// //
if (avi.uid == 0) { if (avi.uid == 0) {
// debugPrint("wgs输出===RTC-用户音量提示(自己):${CountMicrophoneVolume.getVolume(avi.volume!)}"); // debugPrint("wgs输出===RTC-用户音量提示(自己):${CountMicrophoneVolume.getVolume(avi.volume!)}");
@ -910,70 +927,87 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
} }
} }
}*/ }*/
} }
} }
}, },
// //
onClientRoleChanged: (RtcConnection connection, onClientRoleChanged: (RtcConnection connection,
ClientRoleType oldRole, ClientRoleType oldRole,
ClientRoleType newRole, ClientRoleType newRole,
ClientRoleOptions newRoleOptions) { ClientRoleOptions newRoleOptions) {
debugPrint( debugPrint(
"wgs输出===RTC-切换用户角色为:${newRole == ClientRoleType.clientRoleBroadcaster ? "主播" : "观众"}"); "wgs输出===RTC-切换用户角色为:${newRole == ClientRoleType.clientRoleBroadcaster ? "主播" : "观众"}");
}, },
// token即将在30秒内过期回调 // token即将在30秒内过期回调
onTokenPrivilegeWillExpire: (RtcConnection connection, String token) { onTokenPrivilegeWillExpire: (RtcConnection connection, String token) {
doHttpGetMeetingToken(false); doHttpGetMeetingToken(false);
}, },
// //
onLocalVideoStateChanged: (VideoSourceType source, onLocalVideoStateChanged: (VideoSourceType source,
LocalVideoStreamState state, LocalVideoStreamReason reason) { LocalVideoStreamState state, LocalVideoStreamReason reason) {
debugPrint("wgs输出===RTC-本地视频状态发生改变:$source--$state--$reason"); debugPrint("wgs输出===RTC-本地视频状态发生改变:$source--$state--$reason");
}, },
// //
onConnectionStateChanged: (RtcConnection connection, onConnectionStateChanged: (RtcConnection connection,
ConnectionStateType stateType, ConnectionStateType stateType,
ConnectionChangedReasonType reason) { ConnectionChangedReasonType reason) {
debugPrint("wgs输出===RTC-网络连接状态发生改变:" debugPrint("wgs输出===RTC-网络连接状态发生改变:"
"会议室编号(${connection.channelId}" "会议室编号(${connection.channelId}"
"网络状态($stateType-${AgoraUtil.getConnectionStateChangedType(stateType)}" "网络状态($stateType-${AgoraUtil.getConnectionStateChangedType(stateType)}"
"网络改变原因($reason-${AgoraUtil.getConnectionChangedReasonType(reason)}"); "网络改变原因($reason-${AgoraUtil.getConnectionChangedReasonType(reason)}");
if (stateType == ConnectionStateType.connectionStateReconnecting) { if (stateType == ConnectionStateType.connectionStateReconnecting) {
if (EasyLoading.isShow == false) { if (EasyLoading.isShow == false) {
ToastUtils.showLoadingToMask( ToastUtils.showLoadingToMask(
"网络故障,正在重连...", EasyLoadingMaskType.black); "网络故障,正在重连...", EasyLoadingMaskType.black);
} }
} else if (stateType == ConnectionStateType.connectionStateConnected && } else if (stateType ==
reason == ConnectionStateType.connectionStateConnected &&
ConnectionChangedReasonType.connectionChangedRejoinSuccess) { reason ==
ToastUtils.dismiss(); ConnectionChangedReasonType
if (EasyLoading.isShow == false) { .connectionChangedRejoinSuccess) {
ToastUtils.showSuccessToMask("重连成功!", EasyLoadingMaskType.black); ToastUtils.dismiss();
} if (EasyLoading.isShow == false) {
} else if (reason == ToastUtils.showSuccessToMask(
ConnectionChangedReasonType.connectionChangedLost) { "重连成功!", EasyLoadingMaskType.black);
// 15signalR Socket一致SDK继续重连 }
Future.delayed(const Duration(milliseconds: 15000), () { } else if (reason ==
ToastUtils.dismiss(); ConnectionChangedReasonType.connectionChangedLost) {
if (state.isShowOkAlertDialog.value == false) { // 15signalR Socket一致SDK继续重连
showOkAlertDialog( Future.delayed(const Duration(milliseconds: 15000), () {
context: Get.context!, ToastUtils.dismiss();
title: "提示", if (state.isShowOkAlertDialog.value == false) {
message: "网络错误,请重新加入会议室", showOkAlertDialog(
okLabel: "确定", context: Get.context!,
barrierDismissible: false, title: "提示",
).then((OkCancelResult value) { message: "网络错误,请重新加入会议室",
Get.back(); okLabel: "确定",
Get.back(); barrierDismissible: false,
).then((OkCancelResult value) {
Get.back();
Get.back();
});
}
}); });
} }
}); },
}
} //
onFirstRemoteVideoFrame: (RtcConnection connection, int remoteUid,
int width, int height, int elapsed) async {
debugPrint("wgs输出===RTC-渲染器已接收首帧远端视频回调:${remoteUid}--${width}--${height}--${elapsed}");
},
//
onFirstRemoteVideoDecoded: (RtcConnection connection, int remoteUid,
int width, int height, int elapsed) {
debugPrint("wgs输出===RTC-已接收到远端视频并完成解码回调:${remoteUid}--${width}--${height}--${elapsed}");
}
// //
/*onPermissionError: (PermissionType permissionType){ /*onPermissionError: (PermissionType permissionType){
@ -986,6 +1020,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
}*/ }*/
), ),
); );
await joinMeetingToRtc();
} }
/// ///

View File

@ -101,7 +101,7 @@ class MeetingMainState {
/// ///
final String appId = "4a4f7be64fa1404ebda74784fe9ac381"; final String appId = "4a4f7be64fa1404ebda74784fe9ac381";
late Rx<RtcEngineEx?> rctEngine = Rx(null); Rx<RtcEngineEx?> rctEngine = Rx<RtcEngineEx?>(null);
/// ///
late RxBool isAutoSubscribeVideo = false.obs; late RxBool isAutoSubscribeVideo = false.obs;
/// ///

View File

@ -222,8 +222,7 @@ class MeetingMainPageState extends State<MeetingMainPage> {
visible: state.pageState.value == 1, visible: state.pageState.value == 1,
child: state.isJoinSuccess.value == true && child: state.isJoinSuccess.value == true &&
null != state.rctEngine.value && null != state.rctEngine.value &&
null != state.users.value && state.users.isNotEmpty
state.users.value.isNotEmpty
? Stack( ? Stack(
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
@ -305,7 +304,7 @@ class MeetingMainPageState extends State<MeetingMainPage> {
], ],
) )
: Container( : Container(
color: ColorUtil.Color_57_57_57, color: Colors.red,
/*child: Text('加载反馈:是否成功加入会议室${state.isJoinSuccess.value}-会议室对象${state.rctEngine.value}-成员列表${state.users.value.length}-全员观看ID${state.remoteUid.value}'),*/ /*child: Text('加载反馈:是否成功加入会议室${state.isJoinSuccess.value}-会议室对象${state.rctEngine.value}-成员列表${state.users.value.length}-全员观看ID${state.remoteUid.value}'),*/
)), )),