优化重连机制
This commit is contained in:
parent
9188731ce0
commit
067c9a1042
|
|
@ -77,6 +77,7 @@
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
&-content {
|
&-content {
|
||||||
|
height: 0;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
|
||||||
|
|
@ -216,6 +216,7 @@ Page({
|
||||||
if (item && !item.isRoomManager) {
|
if (item && !item.isRoomManager) {
|
||||||
wx.showLoading({
|
wx.showLoading({
|
||||||
title: '重连中',
|
title: '重连中',
|
||||||
|
mask: true
|
||||||
})
|
})
|
||||||
agora.destroy(() => {
|
agora.destroy(() => {
|
||||||
reconnectTime = setInterval(() => {
|
reconnectTime = setInterval(() => {
|
||||||
|
|
@ -250,18 +251,20 @@ Page({
|
||||||
offSignalr()
|
offSignalr()
|
||||||
await GetRoomRtcToken(this.data.channelId).then(res => {
|
await GetRoomRtcToken(this.data.channelId).then(res => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
agora.reconnecSetOption(res.data, async () => {
|
agora.reconnecSetOption(res.data, async (bool) => {
|
||||||
await this.joinChannel()
|
if (bool) {
|
||||||
this.startClientEvent()
|
await this.joinChannel()
|
||||||
this.startSignalr()
|
this.startClientEvent()
|
||||||
await this.getRoomUser()
|
this.startSignalr()
|
||||||
await this.getShowUser()
|
await this.getRoomUser()
|
||||||
|
await this.getShowUser()
|
||||||
|
}
|
||||||
wx.hideLoading()
|
wx.hideLoading()
|
||||||
Message.success({
|
Message.success({
|
||||||
context: this,
|
context: this,
|
||||||
offset: [20, 32],
|
offset: [20, 32],
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
content: '重连成功',
|
content: bool ? '重连成功' : '重连失败,请退出房间重试!',
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,9 @@ export const agora = {
|
||||||
init: async (callback?) => {
|
init: async (callback?) => {
|
||||||
client = new AgoraMiniappSDK.Client();
|
client = new AgoraMiniappSDK.Client();
|
||||||
await client.init(option.appId, () => {
|
await client.init(option.appId, () => {
|
||||||
callback?.()
|
callback?.(true)
|
||||||
|
}, () => {
|
||||||
|
callback?.(false)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 销毁
|
// 销毁
|
||||||
|
|
@ -24,6 +26,8 @@ export const agora = {
|
||||||
callback?.()
|
callback?.()
|
||||||
client = '';
|
client = '';
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
callback?.()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 设置角色
|
// 设置角色
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
const apiBase = "https://meeting-api.23544.com/pc"
|
|
||||||
// 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/test29"
|
||||||
import { Message } from 'tdesign-miniprogram';
|
import { Message } from 'tdesign-miniprogram';
|
||||||
export const Request = (params) => {
|
export const Request = (params) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
let connection = '' as any;
|
let connection = '' as any;
|
||||||
// let url = 'http://192.168.2.9:5192'
|
// let url = 'http://192.168.2.9:5192'
|
||||||
let url = 'https://meeting-api.23544.com/pc'
|
let url = 'https://meeting-api.23544.com/pc'
|
||||||
|
// let url = 'https://meeting-api.23544.com/test29'
|
||||||
import * as signalR from "signalr-for-wx";
|
import * as signalR from "signalr-for-wx";
|
||||||
import { agora } from "./agora";
|
import { agora } from "./agora";
|
||||||
export const startSignalr = async (callBack: Function) => {
|
export const startSignalr = async (callBack: Function) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue