优化重连机制

This commit is contained in:
yj 2025-02-13 10:53:32 +08:00
parent 9188731ce0
commit 067c9a1042
5 changed files with 19 additions and 9 deletions

View File

@ -77,6 +77,7 @@
overflow: hidden;
&-content {
height: 0;
flex-grow: 1;
display: flex;
position: relative;

View File

@ -216,6 +216,7 @@ Page({
if (item && !item.isRoomManager) {
wx.showLoading({
title: '重连中',
mask: true
})
agora.destroy(() => {
reconnectTime = setInterval(() => {
@ -250,18 +251,20 @@ Page({
offSignalr()
await GetRoomRtcToken(this.data.channelId).then(res => {
if (res.code === 200) {
agora.reconnecSetOption(res.data, async () => {
agora.reconnecSetOption(res.data, async (bool) => {
if (bool) {
await this.joinChannel()
this.startClientEvent()
this.startSignalr()
await this.getRoomUser()
await this.getShowUser()
}
wx.hideLoading()
Message.success({
context: this,
offset: [20, 32],
duration: 3000,
content: '重连成功',
content: bool ? '重连成功' : '重连失败,请退出房间重试!',
});
})
} else {

View File

@ -13,7 +13,9 @@ export const agora = {
init: async (callback?) => {
client = new AgoraMiniappSDK.Client();
await client.init(option.appId, () => {
callback?.()
callback?.(true)
}, () => {
callback?.(false)
});
},
// 销毁
@ -24,6 +26,8 @@ export const agora = {
callback?.()
client = '';
})
} else {
callback?.()
}
},
// 设置角色

View File

@ -1,5 +1,6 @@
const apiBase = "https://meeting-api.23544.com/pc"
// const apiBase = "http://192.168.2.9:5192"
const apiBase = "https://meeting-api.23544.com/pc"
// const apiBase = "https://meeting-api.23544.com/test29"
import { Message } from 'tdesign-miniprogram';
export const Request = (params) => {
return new Promise((resolve, reject) => {

View File

@ -1,6 +1,7 @@
let connection = '' as any;
// let url = 'http://192.168.2.9:5192'
let url = 'https://meeting-api.23544.com/pc'
// let url = 'https://meeting-api.23544.com/test29'
import * as signalR from "signalr-for-wx";
import { agora } from "./agora";
export const startSignalr = async (callBack: Function) => {