重构NetManager支持MessagePair,新增TSRPCWsClient。
This commit is contained in:
19
client/assets/scripts/App/Msg/Pair/SendMessagePair.ts
Normal file
19
client/assets/scripts/App/Msg/Pair/SendMessagePair.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { MsgReqSend } from '../../../Shared/protocols/MsgReqSend';
|
||||
import { MsgResSend } from '../../../Shared/protocols/MsgResSend';
|
||||
import { MessagePair } from '../MessagePairBase';
|
||||
|
||||
/**
|
||||
* 发送消息对实现
|
||||
*/
|
||||
export class SendMessagePair extends MessagePair<MsgReqSend, MsgResSend> {
|
||||
readonly requestName = 'ReqSend';
|
||||
readonly responseName = 'ResSend';
|
||||
|
||||
isValidRequest(msg: any): msg is MsgReqSend {
|
||||
return msg && typeof msg.content === 'string';
|
||||
}
|
||||
|
||||
isValidResponse(msg: any): msg is MsgResSend {
|
||||
return msg && msg.time instanceof Date;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user