mirror of
https://github.com/xfgryujk/blivechat.git
synced 2024-12-26 04:41:40 +08:00
同一个房间连接数超过上限时报致命错误
This commit is contained in:
parent
5f744c8214
commit
68fd680ec4
@ -44,6 +44,7 @@ class ContentType(enum.IntEnum):
|
||||
class FatalErrorType(enum.IntEnum):
|
||||
AUTH_CODE_ERROR = 1
|
||||
TOO_MANY_RETRIES = 2
|
||||
TOO_MANY_CONNECTIONS = 3
|
||||
|
||||
|
||||
def make_message_body(cmd, data):
|
||||
|
@ -45,8 +45,11 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
|
||||
if (res.code === 7007) {
|
||||
// 身份码错误
|
||||
throw new chatModels.ChatClientFatalError(chatModels.FATAL_ERROR_TYPE_AUTH_CODE_ERROR, msg)
|
||||
} else if (res.code === 7010) {
|
||||
// 同一个房间连接数超过上限
|
||||
throw new chatModels.ChatClientFatalError(chatModels.FATAL_ERROR_TYPE_TOO_MANY_CONNECTIONS, msg)
|
||||
}
|
||||
throw Error(msg)
|
||||
throw new Error(msg)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('startGame failed:', e)
|
||||
@ -87,7 +90,7 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
|
||||
})).data
|
||||
// 项目已经关闭了也算成功
|
||||
if ([0, 7000, 7003].indexOf(res.code) === -1) {
|
||||
throw Error(`code=${res.code}, message=${res.message}, request_id=${res.request_id}`)
|
||||
throw new Error(`code=${res.code}, message=${res.message}, request_id=${res.request_id}`)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('endGame failed:', e)
|
||||
@ -125,7 +128,7 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
|
||||
this.needInitRoom = true
|
||||
this.discardWebsocket()
|
||||
}
|
||||
throw Error(`code=${res.code}, message=${res.message}, request_id=${res.request_id}`)
|
||||
throw new Error(`code=${res.code}, message=${res.message}, request_id=${res.request_id}`)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('sendGameHeartbeat failed:', e)
|
||||
|
@ -69,7 +69,7 @@ export default class ChatClientOfficialBase {
|
||||
}
|
||||
|
||||
async initRoom() {
|
||||
throw Error('Not implemented')
|
||||
throw new Error('Not implemented')
|
||||
}
|
||||
|
||||
makePacket(data, operation) {
|
||||
@ -95,7 +95,7 @@ export default class ChatClientOfficialBase {
|
||||
}
|
||||
|
||||
sendAuth() {
|
||||
throw Error('Not implemented')
|
||||
throw new Error('Not implemented')
|
||||
}
|
||||
|
||||
addDebugMsg(content) {
|
||||
@ -139,13 +139,13 @@ export default class ChatClientOfficialBase {
|
||||
|
||||
if (!res) {
|
||||
window.setTimeout(() => this.onWsClose(), 0)
|
||||
throw Error('initRoom failed')
|
||||
throw new Error('initRoom failed')
|
||||
}
|
||||
this.needInitRoom = false
|
||||
}
|
||||
|
||||
getWsUrl() {
|
||||
throw Error('Not implemented')
|
||||
throw new Error('Not implemented')
|
||||
}
|
||||
|
||||
onWsOpen() {
|
||||
|
@ -114,6 +114,7 @@ export class UpdateTranslationMsg {
|
||||
|
||||
export const FATAL_ERROR_TYPE_AUTH_CODE_ERROR = 1
|
||||
export const FATAL_ERROR_TYPE_TOO_MANY_RETRIES = 2
|
||||
export const FATAL_ERROR_TYPE_TOO_MANY_CONNECTIONS = 3
|
||||
|
||||
export class ChatClientFatalError extends Error {
|
||||
constructor(type, message) {
|
||||
|
@ -349,7 +349,7 @@ export default {
|
||||
onFatalError(error) {
|
||||
this.$message.error({
|
||||
message: error.toString(),
|
||||
duration: 10 * 1000
|
||||
duration: 30 * 1000
|
||||
})
|
||||
this.onAddText(new chatModels.AddTextMsg({
|
||||
authorName: 'blivechat',
|
||||
|
@ -278,6 +278,14 @@ class OpenLiveClient(blivedm.OpenLiveClient):
|
||||
'type': api.chat.FatalErrorType.AUTH_CODE_ERROR,
|
||||
'msg': str(e)
|
||||
})
|
||||
elif e.code == 7010:
|
||||
# 同一个房间连接数超过上限
|
||||
room = client_room_manager.get_room(self.room_key)
|
||||
if room is not None:
|
||||
room.send_cmd_data(api.chat.Command.FATAL_ERROR, {
|
||||
'type': api.chat.FatalErrorType.TOO_MANY_CONNECTIONS,
|
||||
'msg': str(e)
|
||||
})
|
||||
|
||||
return False
|
||||
return self._parse_start_game(data['data'])
|
||||
|
Loading…
Reference in New Issue
Block a user