修改接受消息的日志方法

This commit is contained in:
zhl 2020-12-08 17:27:19 +08:00
parent 8b9b07ff1c
commit a573dc4be6
2 changed files with 11 additions and 9 deletions

View File

@ -3,3 +3,5 @@ import debug from 'debug';
export const debugRoom = debug('jc:room');
export const error = debug('jc:error');
export const msgLog = debug('jc:msg');

View File

@ -11,7 +11,7 @@ import {SelectHeroCommand} from "./commands/SelectHeroCommand";
import {EatCardCommand} from "./commands/EatCardCommand";
import {GiveUpCommand} from "./commands/GiveUpCommand";
import {BattleHandler} from "./logic/Handler/BattleHandler";
import {debugRoom} from "../common/Debug";
import {debugRoom, msgLog} from "../common/Debug";
import {Delayed} from "@gamestdio/timer/lib/Delayed";
import {IncomingMessage} from "http";
import {BaseConst} from "../constants/BaseConst";
@ -39,34 +39,34 @@ export class GeneralRoom extends Room {
this.clock.start();
this.state.gameSate = 0;
this.onMessage("play_ready_c2s", (client, message) => {
debugRoom('play_ready from ', client.sessionId, message);
msgLog('play_ready from ', client.sessionId, message);
this.dispatcher.dispatch(new PlayReadyCommand(), {client});
});
this.onMessage("change_card_c2s", (client, message) => {
debugRoom('change_card from ', client.sessionId, message);
msgLog('change_card from ', client.sessionId, message);
this.dispatcher.dispatch(new ChangeCardCommand(), {client, cards: message.cards});
});
this.onMessage("discard_card_c2s", (client, message) => {
debugRoom('discard_card from ', client.sessionId, message);
msgLog('discard_card from ', client.sessionId, message);
this.dispatcher.dispatch(new DiscardCommand(), {client, cards: message.cards, dtype: 0});
});
this.onMessage("eat_card_c2s", (client, message) => {
debugRoom('eat_card from ', client.sessionId, message);
msgLog('eat_card from ', client.sessionId, message);
this.dispatcher.dispatch(new EatCardCommand(), {client, cards: message.cards, target: message.target});
});
this.onMessage("give_up_eat_c2s", (client, message) => {
debugRoom('give_up_take from ', client.sessionId, message);
msgLog('give_up_take from ', client.sessionId, message);
this.dispatcher.dispatch(new GiveUpCommand(), {client});
});
this.onMessage("select_pet_c2s", (client, message) => {
debugRoom('select_pet from ', client.sessionId, message);
msgLog('select_pet from ', client.sessionId, message);
this.dispatcher.dispatch(new SelectPetCommand(), {client, cardId: message.card, playerId: message.player, pos: message.pos, effCards: message.effCards });
});
this.onMessage("select_hero_c2s", (client, message) => {
debugRoom('select_hero from ', client.sessionId, message);
msgLog('select_hero from ', client.sessionId, message);
this.dispatcher.dispatch(new SelectHeroCommand(), {client, heroId: message.heroId});
});
@ -75,7 +75,7 @@ export class GeneralRoom extends Room {
// Triggers when any other type of message is sent,
// excluding "action", which has its own specific handler defined above.
//
debugRoom(client.sessionId, "sent", type, message);
msgLog(client.sessionId, "sent", type, message);
});
}