重构NetManager支持MessagePair,新增TSRPCWsClient。
This commit is contained in:
21
client/assets/scripts/App/Msg/Pair/LoginMessagePair.ts
Normal file
21
client/assets/scripts/App/Msg/Pair/LoginMessagePair.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
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';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user