update heartbeat check

This commit is contained in:
2023-11-13 21:31:37 +08:00
parent 0847af205e
commit 7e6ae3afa7
2 changed files with 20 additions and 8 deletions

View File

@@ -152,6 +152,23 @@ function updateUsers() {
}
async function start() {
if (!chatClient) {
await connectRoom()
isConnected.value = true
setInterval(() => {
if (chatClient) {
QueryPostAPI<OpenLiveInfo>(OPEN_LIVE_API_URL + 'heartbeat', authInfo.value).then((data) => {
if (data.code != 200) {
console.error('[OPEN-LIVE] 心跳失败: ' + data.message)
chatClient.stop()
chatClient = null
connectRoom()
}
})
}
}, 20 * 1000)
}
}
async function connectRoom() {
const auth = await get()
if (auth) {
authResult.value = auth
@@ -159,11 +176,6 @@ async function start() {
return
}
initChatClient()
isConnected.value = true
setInterval(() => {
QueryPostAPI<OpenLiveInfo>(OPEN_LIVE_API_URL + 'heartbeat', authInfo.value)
}, 20 * 1000)
}
}
async function initChatClient() {
chatClient = new ChatClientDirectOpenLive(authResult.value)