yangjie #47

Merged
yangqiang merged 49 commits from yangjie into master 2025-01-24 13:43:09 +08:00
2 changed files with 22 additions and 1 deletions
Showing only changes of commit d10fdd1d5c - Show all commits

View File

@ -25,6 +25,7 @@ import { getKeyOpenChildWindow, setKeyOpenChildWindow } from '@/utils/package/pu
import MeetingDisconnected from '@/components/MeetingDisconnected';
import SingIn from '@/components/SingIn';
import UserName from '@/components/UserName';
import { GetRoomRtcToken } from '@/api/Home/Index';
const { setTimeout, setInterval, clearTimeout, clearInterval } = require('timers');
const { confirm } = Modal;
const { exec } = require('child_process');
@ -1155,6 +1156,16 @@ const Meeting: React.FC = () => {
key: 'cameraTemporarily'
});
}
},
onTokenPrivilegeWillExpire: async (connection: RtcConnection, _token: string) => {
await GetRoomRtcToken(connection.channelId || '').then(res => {
if (res.code === 200) {
agora.refreshToken({
token: res.data.token,
connection,
})
}
})
}
})
if (state.enableCamera) {

View File

@ -153,7 +153,7 @@ export const agora = {
}, 1000);
},
// 事件回调
registerEventHandler: ({ onJoinChannelSuccess, onUserJoined, onUserOffline, onAudioVolumeIndication, onNetworkQuality, onRtcStats, onConnectionStateChanged, onLocalVideoStateChanged, onConnectionLost }: any) => {
registerEventHandler: ({ onJoinChannelSuccess, onUserJoined, onUserOffline, onAudioVolumeIndication, onNetworkQuality, onRtcStats, onConnectionStateChanged, onLocalVideoStateChanged, onConnectionLost, onTokenPrivilegeWillExpire }: any) => {
rtcEngine.registerEventHandler({
// 监听本地用户加入频道事件
onJoinChannelSuccess: async (connection: RtcConnection, elapsed: number) => {
@ -202,9 +202,19 @@ export const agora = {
// 网络连接中断,且 SDK 无法在 10 秒内连接服务器回调。
onConnectionLost: (_connection: RtcConnection) => {
onConnectionLost?.()
},
// Token 即将在 30s 内过期回调。
onTokenPrivilegeWillExpire: (connection: RtcConnection, token: string) => {
onTokenPrivilegeWillExpire?.(connection, token)
}
});
},
// 刷新token
refreshToken: async (data: any) => {
await rtcEngine.updateChannelMediaOptionsEx({
token: data.token,
}, data.connection);
},
// 获取视图模式
getRrenderMode: (uid: number) => {
if (String(uid).length === 9) {