This commit is contained in:
yj 2025-02-21 11:52:48 +08:00
parent dddd1e16f5
commit 61c37c4b59
5 changed files with 46 additions and 39 deletions

View File

@ -25,6 +25,9 @@ Page({
key: 'isConnected', key: 'isConnected',
success(res: any) { success(res: any) {
if (res.data) { if (res.data) {
that.setData({
isJoin: false
})
that.setData({ that.setData({
netWorkErrorDialog: true, netWorkErrorDialog: true,
}) })

View File

@ -214,16 +214,7 @@ Page({
this.changeAgoraDevice() this.changeAgoraDevice()
} }
}).catch(() => { }).catch(() => {
wx.setStorage({ this.setIsConnectedBack()
key: "isConnected",
data: true
})
wx.disableAlertBeforeUnload({
complete: () => {
onStop()
wx.navigateBack()
}
})
}) })
}, 1000 * 30) }, 1000 * 30)
} }
@ -379,6 +370,18 @@ Page({
isAutoApplySpeakTime = '' isAutoApplySpeakTime = ''
} }
}, },
setIsConnectedBack() {
wx.setStorage({
key: "isConnected",
data: true
})
wx.disableAlertBeforeUnload({
complete: () => {
onStop()
wx.navigateBack()
}
})
},
showInputPopup() { showInputPopup() {
this.setData({ this.setData({
inputPopupVisible: true, inputPopupVisible: true,
@ -706,7 +709,21 @@ Page({
agora.renewToken(res.data) agora.renewToken(res.data)
} }
}) })
} },
updateUrl: (e) => {
const roomUserListTemp = [...this.data.roomUserList]
const item = roomUserListTemp.find(row => row.uid == e.uid || row.screenShareId == e.uid)
if (item) {
if (String(e.uid).length === 9) {
item.shareSrc = e.url;
} else {
item.src = e.url;
}
}
},
error: (e) => {
this.setIsConnectedBack()
},
}) })
}, },
async getRoomUser(): Promise<void> { async getRoomUser(): Promise<void> {
@ -1166,16 +1183,7 @@ Page({
if (res.isConnected && (res.networkType !== 'none' || res.networkType !== 'unknown')) { if (res.isConnected && (res.networkType !== 'none' || res.networkType !== 'unknown')) {
} else { } else {
wx.setStorage({ this.setIsConnectedBack()
key: "isConnected",
data: true
})
wx.disableAlertBeforeUnload({
complete: () => {
onStop()
wx.navigateBack()
}
})
} }
}, },
closeRoom() { closeRoom() {

View File

@ -64,7 +64,7 @@ export const agora = {
client.renewToken(token) client.renewToken(token)
}, },
// 监听 // 监听
clientEvent: ({ streamAdded, streamRemoved, tokenRef }) => { clientEvent: ({ streamAdded, streamRemoved, tokenRef, updateUrl, error }: any) => {
client.on("stream-added", async e => { client.on("stream-added", async e => {
await agora.subscribe(e.uid, (url: string, uid: number | string) => { await agora.subscribe(e.uid, (url: string, uid: number | string) => {
streamAdded(url, uid) streamAdded(url, uid)
@ -76,6 +76,12 @@ export const agora = {
client.on("token-privilege-will-expire", async e => { client.on("token-privilege-will-expire", async e => {
tokenRef() tokenRef()
}); });
client.on("error", async e => {
error()
});
client.on("update-url", async e => {
updateUrl(e)
});
}, },
// 订阅远端音视频流 // 订阅远端音视频流
subscribe: async (uid: number | string, callBack: Function) => { subscribe: async (uid: number | string, callBack: Function) => {

View File

@ -1,7 +1,6 @@
// const apiBase = "http://192.168.2.9:5192" // const apiBase = "http://192.168.2.9:5192"
const apiBase = "https://meeting-api.23544.com/pc" const apiBase = "https://meeting-api.23544.com/pc"
// const apiBase = "https://meeting-api.23544.com/test29" // const apiBase = "https://meeting-api.23544.com/test29"
import { Message } from 'tdesign-miniprogram';
export const Request = (params) => { export const Request = (params) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
wx.getStorage({ wx.getStorage({
@ -47,21 +46,12 @@ function requestMethods(obj, callback) {
callback('success', res) callback('success', res)
}, },
fail: res => { fail: res => {
if (res.errMsg === 'request:fail timeout') { if (res.errno === 5) {
Message.error({ wx.showToast({
context: this, icon: 'error',
offset: [20, 32], title: '网络连接超时,请检查网络状态',
duration: 2000, mask: true
content: '网络连接超时,请检查网络状态', })
});
}
if (res.errMsg === 'request:fail ') {
Message.error({
context: this,
offset: [20, 32],
duration: 2000,
content: '网络已断开,请检查网络状态',
});
} }
callback('fail', res) callback('fail', res)
}, },

View File

@ -226,7 +226,7 @@ export const onSignalr = (callBack: Function) => {
} }
} }
export const onStop = async () => { export const onStop = async () => {
agora.destroy(); await agora.destroy();
if (connection) { if (connection) {
connection.stop() connection.stop()
connection = ''; connection = '';