Exemplo n.º 1
0
        public async Task <RpcResult <GetUserRsp> > CheckLoginAsync(VoidReq req, int timeOut = 3000)
        {
            AmpMessage message = AmpMessage.CreateRequestMessage(20003, 5);

            message.FriendlyServiceName = "UserService.CheckLogin";
            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);
        }
Exemplo n.º 2
0
        //同步方法
        public RpcResult <GetUserRsp> CheckLogin(VoidReq req)
        {
            AmpMessage message = AmpMessage.CreateRequestMessage(20003, 5);

            message.FriendlyServiceName = "UserService.CheckLogin";


            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);
        }
Exemplo n.º 3
0
        //调用委托
        private async Task <AmpMessage> ProcessCheckLoginAsync(AmpMessage req)
        {
            VoidReq request = null;

            if (req.Data == null)
            {
                request = new VoidReq();
            }
            else
            {
                request = VoidReq.Parser.ParseFrom(req.Data);
            }

            req.FriendlyServiceName = "UserService.CheckLogin";

            var result = await CheckLoginAsync(request);

            var response = AmpMessage.CreateResponseMessage(req.ServiceId, req.MessageId);

            response.FriendlyServiceName = "UserService.CheckLogin";
            response.Code = result.Code;
            if (result.Data != null)
            {
                response.Data = result.Data.ToByteArray();
            }
            return(response);
        }
Exemplo n.º 4
0
 //抽象方法
 public abstract Task <RpcResult <GetUserRsp> > CheckLoginAsync(VoidReq req);