优化声网token刷新逻辑
This commit is contained in:
parent
a019645104
commit
bc3b05403d
|
|
@ -190,6 +190,11 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
|
|||
doHttpGetMeetingToken(false);
|
||||
},
|
||||
|
||||
// token已过期
|
||||
onRequestToken: (RtcConnection connection){
|
||||
doHttpGetMeetingToken(false);
|
||||
},
|
||||
|
||||
// 本地视频状态发生改变回调
|
||||
onLocalVideoStateChanged: (VideoSourceType source,
|
||||
LocalVideoStreamState state, LocalVideoStreamReason reason) {
|
||||
|
|
@ -204,6 +209,10 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
|
|||
"会议室编号(${connection.channelId}),"
|
||||
"网络状态($stateType-${AgoraUtil.getConnectionStateChangedType(stateType)}),"
|
||||
"网络改变原因($reason-${AgoraUtil.getConnectionChangedReasonType(reason)})");
|
||||
if(reason == ConnectionChangedReasonType.connectionChangedTokenExpired){
|
||||
// 当前使用的token已过期
|
||||
doHttpGetMeetingToken(false);
|
||||
}else{
|
||||
if (stateType == ConnectionStateType.connectionStateReconnecting) {
|
||||
if (EasyLoading.isShow == false) {
|
||||
ToastUtils.showLoadingToMask(
|
||||
|
|
@ -238,14 +247,13 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 渲染器已接收首帧远端视频回调
|
||||
onFirstRemoteVideoFrame: (RtcConnection connection, int remoteUid,
|
||||
int width, int height, int elapsed) async {
|
||||
debugPrint("wgs输出===:RTC-渲染器已接收首帧远端视频回调:${remoteUid}--${width}--${height}--${elapsed}");
|
||||
|
||||
|
||||
},
|
||||
|
||||
// 已接收到远端视频并完成解码回调
|
||||
|
|
@ -301,7 +309,8 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
|
|||
if (isInit) {
|
||||
signalRSocket();
|
||||
} else {
|
||||
initRtc();
|
||||
renewToken(state.meetingToken.value);
|
||||
// initRtc();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1122,4 +1131,9 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
|
|||
Future<void> switchCamera() async {
|
||||
await state.rctEngine.value?.switchCamera();
|
||||
}
|
||||
|
||||
/// 更新 Token
|
||||
Future<void> renewToken(String token) async {
|
||||
await state.rctEngine.value?.renewToken(token);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue