重构NetManager支持MessagePair,新增TSRPCWsClient。
This commit is contained in:
23
client/assets/scripts/App/Msg/Pair/MoveMessagePair.ts
Normal file
23
client/assets/scripts/App/Msg/Pair/MoveMessagePair.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { MsgReqMove } from '../../../Shared/protocols/MsgReqMove';
|
||||
import { MsgResMove } from '../../../Shared/protocols/MsgResMove';
|
||||
import { MessagePair } from '../MessagePairBase';
|
||||
|
||||
/**
|
||||
* 移动消息对实现
|
||||
*/
|
||||
export class MoveMessagePair extends MessagePair<MsgReqMove, MsgResMove> {
|
||||
readonly requestName = 'ReqMove';
|
||||
readonly responseName = 'ResMove';
|
||||
|
||||
isValidRequest(msg: any): msg is MsgReqMove {
|
||||
return msg &&
|
||||
typeof msg.x === 'number' &&
|
||||
typeof msg.y === 'number';
|
||||
}
|
||||
|
||||
isValidResponse(msg: any): msg is MsgResMove {
|
||||
return msg &&
|
||||
typeof msg.success === 'boolean' &&
|
||||
typeof msg.message === 'string';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user