mirror of
https://github.com/xfgryujk/blivechat.git
synced 2024-12-25 20:30:28 +08:00
前端房间页面添加调试消息
This commit is contained in:
parent
e4c599ced6
commit
4530bc83c7
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "blivechat",
|
||||
"version": "1.9.0",
|
||||
"version": "1.9.1-dev",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
|
@ -41,9 +41,17 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
|
||||
if (this.gameId && this.gameHeartbeatTimerId === null) {
|
||||
this.gameHeartbeatTimerId = window.setTimeout(this.onSendGameHeartbeat.bind(this), GAME_HEARTBEAT_INTERVAL)
|
||||
}
|
||||
|
||||
this.msgHandler.onDebugMsg(new chatModels.DebugMsg({
|
||||
content: '开始连接房间'
|
||||
}))
|
||||
}
|
||||
|
||||
onWsClose() {
|
||||
this.msgHandler.onDebugMsg(new chatModels.DebugMsg({
|
||||
content: '房间连接已断开'
|
||||
}))
|
||||
|
||||
if (this.gameHeartbeatTimerId) {
|
||||
window.clearTimeout(this.gameHeartbeatTimerId)
|
||||
this.gameHeartbeatTimerId = null
|
||||
@ -69,6 +77,10 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('startGame failed:', e)
|
||||
this.msgHandler.onDebugMsg(new chatModels.DebugMsg({
|
||||
content: `开放平台开启项目失败:${e}`
|
||||
}))
|
||||
|
||||
if (e instanceof chatModels.ChatClientFatalError) {
|
||||
throw e
|
||||
}
|
||||
@ -87,6 +99,10 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
|
||||
}
|
||||
|
||||
async endGame() {
|
||||
this.msgHandler.onDebugMsg(new chatModels.DebugMsg({
|
||||
content: '开放平台关闭项目'
|
||||
}))
|
||||
|
||||
if (!this.gameId) {
|
||||
return true
|
||||
}
|
||||
@ -130,6 +146,9 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
|
||||
})).data
|
||||
if (res.code !== 0) {
|
||||
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) {
|
||||
// 项目异常关闭,可能是心跳超时,需要重新开启项目
|
||||
@ -141,6 +160,9 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('sendGameHeartbeat failed:', e)
|
||||
this.msgHandler.onDebugMsg(new chatModels.DebugMsg({
|
||||
content: `开放平台项目心跳失败:${e}`
|
||||
}))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@ -161,6 +183,10 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
|
||||
}
|
||||
|
||||
sendAuth() {
|
||||
this.msgHandler.onDebugMsg(new chatModels.DebugMsg({
|
||||
content: '已连接到房间,发送认证消息'
|
||||
}))
|
||||
|
||||
this.websocket.send(this.makePacket(this.authBody, base.OP_AUTH))
|
||||
}
|
||||
|
||||
@ -171,6 +197,10 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
|
||||
this.endGame()
|
||||
}
|
||||
|
||||
this.msgHandler.onDebugMsg(new chatModels.DebugMsg({
|
||||
content: `计划下次重连,当前页面${document.visibilityState === 'visible' ? '可见' : '不可见'}`
|
||||
}))
|
||||
|
||||
super.delayReconnect()
|
||||
}
|
||||
|
||||
|
@ -121,3 +121,11 @@ export class ChatClientFatalError extends Error {
|
||||
this.type = type
|
||||
}
|
||||
}
|
||||
|
||||
export class DebugMsg {
|
||||
constructor({
|
||||
content = '',
|
||||
} = {}) {
|
||||
this.content = content
|
||||
}
|
||||
}
|
||||
|
@ -362,6 +362,15 @@ export default {
|
||||
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) {
|
||||
if (this.config.blockGiftDanmaku && data.isGiftDanmaku) {
|
||||
|
Loading…
Reference in New Issue
Block a user