Esempio n. 1
0
        private void ChallengeUserCallback(RPCContext context)
        {
            ChallengeUserRequest challengeUserRequest = ChallengeUserRequest.ParseFrom(context.Payload);

            if (!challengeUserRequest.IsInitialized)
            {
                return;
            }
            ulong num  = (ulong)challengeUserRequest.Id;
            bool  flag = false;

            for (int i = 0; i < challengeUserRequest.ChallengesCount; i++)
            {
                Challenge challenge = challengeUserRequest.Challenges[i];
                if (challenge.Type == 5265220u)
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                this.AbortChallenge(num);
                return;
            }
            ChallengePickedRequest challengePickedRequest = new ChallengePickedRequest();

            challengePickedRequest.SetChallenge(5265220u);
            challengePickedRequest.SetId((uint)num);
            challengePickedRequest.SetNewChallengeProtocol(true);
            RPCContext    rpccontext = this.m_rpcConnection.QueueRequest(this.ChallengeService.Id, 1u, challengePickedRequest, new RPCContextDelegate(this.ChallengedPickedCallback), 0u);
            ChallengeInfo value      = default(ChallengeInfo);

            value.challengeId = num;
            value.isRetry     = false;
            this.m_challengePendingList.Add(rpccontext.Header.Token, value);
        }
Esempio n. 2
0
    private void ChallengeUserCallback(RPCContext context)
    {
        ChallengeUserRequest request = ChallengeUserRequest.ParseFrom(context.Payload);

        if (request.IsInitialized)
        {
            ulong id   = request.Id;
            bool  flag = false;
            for (int i = 0; i < request.ChallengesCount; i++)
            {
                Challenge challenge = request.Challenges[i];
                if (challenge.Type == 0x505744)
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                this.AbortChallenge(id);
            }
            else
            {
                ChallengePickedRequest message = new ChallengePickedRequest();
                message.SetChallenge(0x505744);
                message.SetId((uint)id);
                message.SetNewChallengeProtocol(true);
                RPCContext context2             = base.m_rpcConnection.QueueRequest(this.ChallengeService.Id, 1, message, new RPCContextDelegate(this.ChallengedPickedCallback), 0);
                BattleNet.DllChallengeInfo info = new BattleNet.DllChallengeInfo {
                    challengeId = id,
                    isRetry     = false
                };
                this.m_challengePendingList.Add(context2.Header.Token, info);
            }
        }
    }
        public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
        {
            switch (methodId)
            {
            case 1:
            {
                ChallengePickedRequest request = new ChallengePickedRequest();
                request.MergeFrom(stream);


                ChallengePickedResponse response = new ChallengePickedResponse();
                BattlenetRpcErrorCode   status   = HandleChallengePicked(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChallengeService.ChallengePicked(bgs.protocol.challenge.v1.ChallengePickedRequest: {1}) returned bgs.protocol.challenge.v1.ChallengePickedResponse: {2} status: {3}.",
                             GetCallerInfo(), request.ToString(), response.ToString(), status);
                if (status == 0)
                {
                    SendResponse(token, response);
                }
                else
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 2:
            {
                ChallengeAnsweredRequest request = new ChallengeAnsweredRequest();
                request.MergeFrom(stream);


                ChallengeAnsweredResponse response = new ChallengeAnsweredResponse();
                BattlenetRpcErrorCode     status   = HandleChallengeAnswered(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChallengeService.ChallengeAnswered(bgs.protocol.challenge.v1.ChallengeAnsweredRequest: {1}) returned bgs.protocol.challenge.v1.ChallengeAnsweredResponse: {2} status: {3}.",
                             GetCallerInfo(), request.ToString(), response.ToString(), status);
                if (status == 0)
                {
                    SendResponse(token, response);
                }
                else
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 3:
            {
                ChallengeCancelledRequest request = new ChallengeCancelledRequest();
                request.MergeFrom(stream);


                NoData response = new NoData();
                BattlenetRpcErrorCode status = HandleChallengeCancelled(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChallengeService.ChallengeCancelled(bgs.protocol.challenge.v1.ChallengeCancelledRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
                             GetCallerInfo(), request.ToString(), response.ToString(), status);
                if (status == 0)
                {
                    SendResponse(token, response);
                }
                else
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 4:
            {
                SendChallengeToUserRequest request = new SendChallengeToUserRequest();
                request.MergeFrom(stream);


                SendChallengeToUserResponse response = new SendChallengeToUserResponse();
                BattlenetRpcErrorCode       status   = HandleSendChallengeToUser(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChallengeService.SendChallengeToUser(bgs.protocol.challenge.v1.SendChallengeToUserRequest: {1}) returned bgs.protocol.challenge.v1.SendChallengeToUserResponse: {2} status: {3}.",
                             GetCallerInfo(), request.ToString(), response.ToString(), status);
                if (status == 0)
                {
                    SendResponse(token, response);
                }
                else
                {
                    SendResponse(token, status);
                }
                break;
            }

            default:
                Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
                SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
                break;
            }
        }
 BattlenetRpcErrorCode HandleChallengePicked(ChallengePickedRequest request, ChallengePickedResponse response)
 {
     Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChallengeService.ChallengePicked: {1}",
                  GetCallerInfo(), request.ToString());
     return(BattlenetRpcErrorCode.RpcNotImplemented);
 }