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';
    }
}