Files
rougelike-demo/client/assets/scripts/App/Msg/Pair/LoginMessagePair.ts

21 lines
688 B
TypeScript

import { MsgReqLogin } from '../../../Shared/protocols/MsgReqLogin';
import { MsgResLogin } from '../../../Shared/protocols/MsgResLogin';
import { MessagePair } from '../MessagePairBase';
/**
* 登录消息对实现
*/
export class LoginMessagePair extends MessagePair<MsgReqLogin, MsgResLogin> {
readonly requestName = 'ReqLogin';
readonly responseName = 'ResLogin';
isValidRequest(msg: any): msg is MsgReqLogin {
return msg && typeof msg.playerId === 'string';
}
isValidResponse(msg: any): msg is MsgResLogin {
return msg &&
typeof msg.success === 'boolean' &&
typeof msg.message === 'string';
}
}