前端房间页面添加调试消息

pull/171/head
John Smith 7 months ago
parent e4c599ced6
commit 4530bc83c7

@ -1,6 +1,6 @@
{ {
"name": "blivechat", "name": "blivechat",
"version": "1.9.0", "version": "1.9.1-dev",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",

@ -41,9 +41,17 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
if (this.gameId && this.gameHeartbeatTimerId === null) { if (this.gameId && this.gameHeartbeatTimerId === null) {
this.gameHeartbeatTimerId = window.setTimeout(this.onSendGameHeartbeat.bind(this), GAME_HEARTBEAT_INTERVAL) this.gameHeartbeatTimerId = window.setTimeout(this.onSendGameHeartbeat.bind(this), GAME_HEARTBEAT_INTERVAL)
} }
this.msgHandler.onDebugMsg(new chatModels.DebugMsg({
content: '开始连接房间'
}))
} }
onWsClose() { onWsClose() {
this.msgHandler.onDebugMsg(new chatModels.DebugMsg({
content: '房间连接已断开'
}))
if (this.gameHeartbeatTimerId) { if (this.gameHeartbeatTimerId) {
window.clearTimeout(this.gameHeartbeatTimerId) window.clearTimeout(this.gameHeartbeatTimerId)
this.gameHeartbeatTimerId = null this.gameHeartbeatTimerId = null
@ -69,6 +77,10 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
} }
} catch (e) { } catch (e) {
console.error('startGame failed:', e) console.error('startGame failed:', e)
this.msgHandler.onDebugMsg(new chatModels.DebugMsg({
content: `开放平台开启项目失败:${e}`
}))
if (e instanceof chatModels.ChatClientFatalError) { if (e instanceof chatModels.ChatClientFatalError) {
throw e throw e
} }
@ -87,6 +99,10 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
} }
async endGame() { async endGame() {
this.msgHandler.onDebugMsg(new chatModels.DebugMsg({
content: '开放平台关闭项目'
}))
if (!this.gameId) { if (!this.gameId) {
return true return true
} }
@ -130,6 +146,9 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
})).data })).data
if (res.code !== 0) { if (res.code !== 0) {
console.error(`sendGameHeartbeat failed: code=${res.code}, message=${res.message}, request_id=${res.request_id}`) console.error(`sendGameHeartbeat failed: code=${res.code}, message=${res.message}, request_id=${res.request_id}`)
this.msgHandler.onDebugMsg(new chatModels.DebugMsg({
content: `开放平台项目心跳失败code=${res.code}, message=${res.message}`
}))
if (res.code === 7003 && this.gameId === gameId) { if (res.code === 7003 && this.gameId === gameId) {
// 项目异常关闭,可能是心跳超时,需要重新开启项目 // 项目异常关闭,可能是心跳超时,需要重新开启项目
@ -141,6 +160,9 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
} }
} catch (e) { } catch (e) {
console.error('sendGameHeartbeat failed:', e) console.error('sendGameHeartbeat failed:', e)
this.msgHandler.onDebugMsg(new chatModels.DebugMsg({
content: `开放平台项目心跳失败:${e}`
}))
return false return false
} }
return true return true
@ -161,6 +183,10 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
} }
sendAuth() { sendAuth() {
this.msgHandler.onDebugMsg(new chatModels.DebugMsg({
content: '已连接到房间,发送认证消息'
}))
this.websocket.send(this.makePacket(this.authBody, base.OP_AUTH)) this.websocket.send(this.makePacket(this.authBody, base.OP_AUTH))
} }
@ -171,6 +197,10 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
this.endGame() this.endGame()
} }
this.msgHandler.onDebugMsg(new chatModels.DebugMsg({
content: `计划下次重连,当前页面${document.visibilityState === 'visible' ? '可见' : '不可见'}`
}))
super.delayReconnect() super.delayReconnect()
} }

@ -121,3 +121,11 @@ export class ChatClientFatalError extends Error {
this.type = type this.type = type
} }
} }
export class DebugMsg {
constructor({
content = '',
} = {}) {
this.content = content
}
}

@ -362,6 +362,15 @@ export default {
this.$router.push({ name: 'help' }) this.$router.push({ name: 'help' })
} }
}, },
/** @param {chatModels.DebugMsg} data */
onDebugMsg(data) {
this.onAddText(new chatModels.AddTextMsg({
authorName: 'blivechat',
authorType: constants.AUTHOR_TYPE_ADMIN,
content: data.content,
authorLevel: 60,
}))
},
filterTextMessage(data) { filterTextMessage(data) {
if (this.config.blockGiftDanmaku && data.isGiftDanmaku) { if (this.config.blockGiftDanmaku && data.isGiftDanmaku) {

Loading…
Cancel
Save