From 8baf55247978dc6a29e96bb43253b49df2a1660f Mon Sep 17 00:00:00 2001 From: zhl Date: Fri, 29 Jan 2021 15:58:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8C=B9=E9=85=8D=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/WebApi.ts | 7 ++++--- src/rooms/RankedLobbyRoom.ts | 4 +++- src/rooms/commands/OnJoinCommand.ts | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/common/WebApi.ts b/src/common/WebApi.ts index 54e2d8f..8088f72 100644 --- a/src/common/WebApi.ts +++ b/src/common/WebApi.ts @@ -23,8 +23,8 @@ export function getCardGroup(accountid: string, heroid: number, cardgroup: strin }) } -export function getUserInfo(accountid: string) { - return axios.get(`${ config.info_svr }/${ accountid }/uinfo`) +export function getUserInfo(accountid: string, isMatch: boolean) { + return axios.post(`${ config.info_svr }/${ accountid }/uinfo`, {isMatch}) .then(function (response) { let res = response.data if (res.errcode) { @@ -123,7 +123,8 @@ export async function checkMatchTicket(accountid: string, matchid: string) { return axios(reqConfig).then(function (response) { let res = response.data if (res.errcode) { - throw new Error(res.errmsg) + error(`check match ticket error with code: ${res.errcode}, msg: ${res.errmsg}`) + throw new Error(res.errcode) } else { return {} } diff --git a/src/rooms/RankedLobbyRoom.ts b/src/rooms/RankedLobbyRoom.ts index 2ce20bd..c487be6 100644 --- a/src/rooms/RankedLobbyRoom.ts +++ b/src/rooms/RankedLobbyRoom.ts @@ -2,6 +2,7 @@ import { Client, generateId, matchMaker, Room, ServerError } from 'colyseus' import { BaseConst } from '../constants/BaseConst' import { IncomingMessage } from 'http' import { checkMatchTicket } from '../common/WebApi' +import { error } from '../common/Debug' interface MatchmakingGroup { averageRank: number; @@ -91,7 +92,8 @@ export class RankedLobbyRoom extends Room { try { await checkMatchTicket(accountid, this.matchid) } catch (err) { - throw new ServerError(11, 'not enough ticket') + let code = isNaN(err.message) ? 9: parseInt(err.message) + throw new ServerError(code, 'not enough ticket') } return true } diff --git a/src/rooms/commands/OnJoinCommand.ts b/src/rooms/commands/OnJoinCommand.ts index 3527909..582040d 100644 --- a/src/rooms/commands/OnJoinCommand.ts +++ b/src/rooms/commands/OnJoinCommand.ts @@ -46,7 +46,7 @@ export class OnJoinCommand extends Command