示例#1
0
        public async Task <RpcResult <GetUserRsp> > GetUserInfoAsync(GetUserReq req, int timeOut = 3000)
        {
            AmpMessage message = AmpMessage.CreateRequestMessage(20003, 4);

            message.FriendlyServiceName = "UserService.GetUserInfo";
            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 <GetUserRsp>();

            if (response.Code != 0)
            {
                result.Code = response.Code;
            }

            if (response.Data == null)
            {
                result.Data = new GetUserRsp();
            }
            else
            {
                result.Data = GetUserRsp.Parser.ParseFrom(response.Data);
            }

            return(result);
        }
示例#2
0
        //同步方法
        public RpcResult <GetUserRsp> GetUserInfo(GetUserReq req)
        {
            AmpMessage message = AmpMessage.CreateRequestMessage(20003, 4);

            message.FriendlyServiceName = "UserService.GetUserInfo";


            message.Data = req.ToByteArray();
            var response = base.CallInvoker.BlockingCall(message);

            if (response == null)
            {
                throw new RpcException("error,response is null !");
            }
            var result = new RpcResult <GetUserRsp>();

            if (response.Code != 0)
            {
                result.Code = response.Code;
            }

            if (response.Data == null)
            {
                result.Data = new GetUserRsp();
            }
            else
            {
                result.Data = GetUserRsp.Parser.ParseFrom(response.Data);
            }

            return(result);
        }