public void FindGame(byte[] requestGuid, BnetGameType gameType, int scenario, long deckId, long aiDeckId, bool setScenarioIdAttr)
 {
     if (this.s_gameRequest != 0)
     {
         Debug.LogWarning("WARNING: FindGame called with an active game");
         this.CancelFindGame(this.s_gameRequest);
         this.s_gameRequest = 0L;
     }
     if (this.IsNoAccountTutorialGame(gameType))
     {
         this.GoToNoAccountTutorialServer(scenario);
     }
     else
     {
         object[] args = new object[] { gameType, scenario, deckId, aiDeckId, !setScenarioIdAttr ? 0 : 1, (requestGuid != null) ? requestGuid.ToHexString() : "null" };
         base.ApiLog.LogInfo("FindGame type={0} scenario={1} deck={2} aideck={3} setScenId={4} request_guid={5}", args);
         bnet.protocol.game_master.Player val = new bnet.protocol.game_master.Player();
         Identity identity = new Identity();
         identity.SetGameAccountId(base.m_battleNet.GameAccountId);
         val.SetIdentity(identity);
         val.AddAttribute(ProtocolHelper.CreateAttribute("type", (long)gameType));
         val.AddAttribute(ProtocolHelper.CreateAttribute("scenario", (long)scenario));
         val.AddAttribute(ProtocolHelper.CreateAttribute("deck", (long)((int)deckId)));
         val.AddAttribute(ProtocolHelper.CreateAttribute("aideck", (long)((int)aiDeckId)));
         val.AddAttribute(ProtocolHelper.CreateAttribute("request_guid", requestGuid));
         GameProperties  properties = new GameProperties();
         AttributeFilter filter     = new AttributeFilter();
         filter.SetOp(AttributeFilter.Types.Operation.MATCH_ALL);
         if (!BattleNet.IsVersionInt() && (BattleNet.GetVersionString() == "PAX"))
         {
             filter.AddAttribute(ProtocolHelper.CreateAttribute("version", BattleNet.GetVersionString() + BattleNet.GetVersionInt().ToString()));
         }
         else if (BattleNet.IsVersionInt())
         {
             filter.AddAttribute(ProtocolHelper.CreateAttribute("version", (long)BattleNet.GetVersionInt()));
         }
         else
         {
             filter.AddAttribute(ProtocolHelper.CreateAttribute("version", BattleNet.GetVersionString()));
         }
         filter.AddAttribute(ProtocolHelper.CreateAttribute("GameType", (long)gameType));
         if (setScenarioIdAttr)
         {
             filter.AddAttribute(ProtocolHelper.CreateAttribute("ScenarioId", (long)scenario));
         }
         properties.SetFilter(filter);
         properties.AddCreationAttributes(ProtocolHelper.CreateAttribute("type", (long)gameType));
         properties.AddCreationAttributes(ProtocolHelper.CreateAttribute("scenario", (long)scenario));
         FindGameRequest request = new FindGameRequest();
         request.AddPlayer(val);
         request.SetProperties(properties);
         request.SetAdvancedNotification(true);
         FindGameRequest request2 = request;
         this.PrintFindGameRequest(request2);
         this.IsFindGamePending = true;
         base.m_rpcConnection.QueueRequest(this.m_gameMasterService.Id, 3, request2, new RPCContextDelegate(this.FindGameCallback), 0);
     }
 }
    public void CreateFriendlyChallengeGame(long myDeck, long hisDeck, EntityId hisGameAccount, int scenario)
    {
        FindGameRequest request = new FindGameRequest();

        bnet.protocol.game_master.Player val = new bnet.protocol.game_master.Player();
        Identity identity = new Identity();

        identity.SetGameAccountId(base.m_battleNet.GameAccountId);
        GameProperties  properties = new GameProperties();
        AttributeFilter filter     = new AttributeFilter();

        filter.SetOp(AttributeFilter.Types.Operation.MATCH_ALL);
        if (!BattleNet.IsVersionInt() && (BattleNet.GetVersionString() == "PAX"))
        {
            filter.AddAttribute(ProtocolHelper.CreateAttribute("version", BattleNet.GetVersionString() + BattleNet.GetVersionInt().ToString()));
        }
        else if (BattleNet.IsVersionInt())
        {
            filter.AddAttribute(ProtocolHelper.CreateAttribute("version", (long)BattleNet.GetVersionInt()));
        }
        else
        {
            filter.AddAttribute(ProtocolHelper.CreateAttribute("version", BattleNet.GetVersionString()));
        }
        filter.AddAttribute(ProtocolHelper.CreateAttribute("GameType", (long)1L));
        filter.AddAttribute(ProtocolHelper.CreateAttribute("ScenarioId", (long)scenario));
        properties.SetFilter(filter);
        properties.AddCreationAttributes(ProtocolHelper.CreateAttribute("type", (long)1L));
        properties.AddCreationAttributes(ProtocolHelper.CreateAttribute("scenario", (long)scenario));
        val.SetIdentity(identity);
        val.AddAttribute(ProtocolHelper.CreateAttribute("type", (long)1L));
        val.AddAttribute(ProtocolHelper.CreateAttribute("scenario", (long)scenario));
        val.AddAttribute(ProtocolHelper.CreateAttribute("deck", (long)((int)myDeck)));
        request.AddPlayer(val);
        identity = new Identity();
        val      = new bnet.protocol.game_master.Player();
        identity.SetGameAccountId(hisGameAccount);
        val.SetIdentity(identity);
        val.AddAttribute(ProtocolHelper.CreateAttribute("type", (long)1L));
        val.AddAttribute(ProtocolHelper.CreateAttribute("scenario", (long)scenario));
        val.AddAttribute(ProtocolHelper.CreateAttribute("deck", (long)((int)hisDeck)));
        request.AddPlayer(val);
        request.SetProperties(properties);
        request.SetAdvancedNotification(true);
        FindGameRequest request2 = request;

        this.PrintFindGameRequest(request2);
        this.IsFindGamePending = true;
        base.m_rpcConnection.QueueRequest(this.m_gameMasterService.Id, 3, request2, new RPCContextDelegate(this.FindGameCallback), 0);
    }
    private ClientRequest CreateClientRequest(int type, int sys, byte[] bs, ulong route)
    {
        ClientRequest request = new ClientRequest();

        byte[] dst = new byte[bs.Length + 2];
        dst[0] = (byte)(type & 0xff);
        dst[1] = (byte)((type & 0xff00) >> 8);
        Buffer.BlockCopy(bs, 0, dst, 2, bs.Length);
        request.AddAttribute(ProtocolHelper.CreateAttribute("p", dst));
        if (BattleNet.IsVersionInt())
        {
            request.AddAttribute(ProtocolHelper.CreateAttribute("v", (long)((10 * BattleNet.GetVersionInt()) + sys)));
        }
        else
        {
            request.AddAttribute(ProtocolHelper.CreateAttribute("v", BattleNet.GetVersionString() + ((sys != 0) ? "b" : "c")));
        }
        if (route != 0)
        {
            request.AddAttribute(ProtocolHelper.CreateAttribute("r", route));
        }
        return(request);
    }