//同步方法 public BenchmarkMessage Echo(BenchmarkMessage request) { AmpMessage message = AmpMessage.CreateRequestMessage(50000, 1); message.Data = request.ToByteArray(); var response = base.CallInvoker.BlockingCall(message); if (response != null && response.Data != null) { return(BenchmarkMessage.Parser.ParseFrom(response.Data)); } throw new RpcException("请求出错,请检查!"); }
public async Task <BenchmarkMessage> EchoAsync(BenchmarkMessage request, int timeOut = 3000) { AmpMessage message = AmpMessage.CreateRequestMessage(50000, 1); message.Data = request.ToByteArray(); var response = await base.CallInvoker.AsyncCall(message, timeOut); if (response != null && response.Data != null) { return(BenchmarkMessage.Parser.ParseFrom(response.Data)); } throw new RpcException("请求出错,请检查!"); }
//同步方法 public BenchmarkMessage Echo(BenchmarkMessage request) { AmpMessage message = AmpMessage.CreateRequestMessage(50000, 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 BenchmarkMessage()); } return(BenchmarkMessage.Parser.ParseFrom(response.Data)); }