1.声网token过期回调处理

2.声网切换角色回调输出优化
This commit is contained in:
fuenmao 2024-12-02 15:17:33 +08:00
parent c3e394255a
commit 86724ced8f
1 changed files with 12 additions and 6 deletions

View File

@ -28,7 +28,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
var data = Get.arguments; var data = Get.arguments;
state.roomNumber.value = data["roomNumber"]; state.roomNumber.value = data["roomNumber"];
doHttpGetMeetingToken(); doHttpGetMeetingToken(true);
} }
@override @override
@ -43,12 +43,14 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
} }
/// Token /// Token
Future<void> doHttpGetMeetingToken() async { Future<void> doHttpGetMeetingToken(bool isInit) async {
BaseStructureResult<String> res = await getClient().getMeetingToken(state.roomNumber.value); BaseStructureResult<String> res = await getClient().getMeetingToken(state.roomNumber.value);
state.meetingToken.value = res.data!; state.meetingToken.value = res.data!;
initRtc(); if(isInit == true){
signalRSocket(); initRtc();
signalRSocket();
}
} }
/// ///
@ -492,7 +494,6 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
} }
} }
} }
} }
}, },
@ -502,7 +503,12 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
ClientRoleType oldRole, ClientRoleType oldRole,
ClientRoleType newRole, ClientRoleType newRole,
ClientRoleOptions newRoleOptions){ ClientRoleOptions newRoleOptions){
debugPrint("wgs输出===RTC-切换用户角色"); debugPrint("wgs输出===RTC-切换用户角色为:${newRole == ClientRoleType.clientRoleBroadcaster ? "主播" : "观众"}");
},
// token即将在30秒内过期
onTokenPrivilegeWillExpire: (RtcConnection connection, String token){
doHttpGetMeetingToken(false);
} }
), ),
); );