public async Task <RpcResult <AddRes> > AddAsync(AddReq req, int timeOut = 3000) { AmpMessage message = AmpMessage.CreateRequestMessage(10005, 1); message.FriendlyServiceName = "Math.Add"; message.Data = req.ToByteArray(); var response = await base.CallInvoker.AsyncCall(message, timeOut); if (response == null) { throw new RpcException("error,response is null !"); } var result = new RpcResult <AddRes>(); if (response.Code != 0) { result.Code = response.Code; } if (response.Data == null) { result.Data = new AddRes(); } else { result.Data = AddRes.Parser.ParseFrom(response.Data); } return(result); }
//调用委托 private async Task <AmpMessage> ProcessPlusAsync(AmpMessage req) { AddReq request = null; if (req.Data == null) { request = new AddReq(); } else { request = AddReq.Parser.ParseFrom(req.Data); } req.FriendlyServiceName = "MathInner.Plus"; var result = await PlusAsync(request); var response = AmpMessage.CreateResponseMessage(req.ServiceId, req.MessageId); response.FriendlyServiceName = "MathInner.Plus"; response.Code = result.Code; if (result.Data != null) { response.Data = result.Data.ToByteArray(); } return(response); }
//同步方法 public RpcResult <AddRes> Add(AddReq req) { AmpMessage message = AmpMessage.CreateRequestMessage(10005, 1); message.FriendlyServiceName = "Math.Add"; message.Data = req.ToByteArray(); var response = base.CallInvoker.BlockingCall(message); if (response == null) { throw new RpcException("error,response is null !"); } var result = new RpcResult <AddRes>(); if (response.Code != 0) { result.Code = response.Code; } if (response.Data == null) { result.Data = new AddRes(); } else { result.Data = AddRes.Parser.ParseFrom(response.Data); } return(result); }
//同步方法 public AddRes Add(AddReq request) { AmpMessage message = AmpMessage.CreateRequestMessage(10005, 1); message.Data = request.ToByteArray(); var response = base.CallInvoker.BlockingCall(message); if (response == null) { throw new RpcException("error,response is null !"); } if (response.Data == null) { return(new AddRes()); } return(AddRes.Parser.ParseFrom(response.Data)); }
public async Task <AddRes> AddAsync(AddReq request, int timeOut = 3000) { AmpMessage message = AmpMessage.CreateRequestMessage(10005, 1); message.Data = request.ToByteArray(); var response = await base.CallInvoker.AsyncCall(message, timeOut); if (response == null) { throw new RpcException("error,response is null !"); } if (response.Data == null) { return(new AddRes()); } return(AddRes.Parser.ParseFrom(response.Data)); }
//调用委托 private async Task <AmpMessage> ProcessAddAsync(AmpMessage req) { AddReq request = null; if (req.Data == null) { request = new AddReq(); } else { request = AddReq.Parser.ParseFrom(req.Data); } var data = await AddAsync(request); var response = AmpMessage.CreateResponseMessage(req.ServiceId, req.MessageId); response.Data = data.ToByteArray(); return(response); }
//抽象方法 public abstract Task <RpcResult <AddRes> > PlusAsync(AddReq req);
//抽象方法 public abstract Task <AddRes> AddAsync(AddReq request);