예제 #1
0
    private void GetServerConfig()
    {
        this.configRequested = true;
        string     url  = this.adsUrl + this.adsUrlQueue;
        WebGetTask task = new WebGetTask(url, delegate(bool success, string text)
        {
            if (!this.IsEnabled())
            {
                FMLogger.vAds("recieved ads config, but ads is off");
                return;
            }
            if (success && !string.IsNullOrEmpty(text))
            {
                try
                {
                    byte[] bytes = Convert.FromBase64String(text);
                    text         = Encoding.UTF8.GetString(bytes);
                    char[] array = text.ToCharArray();
                    Array.Reverse(array);
                    text          = new string(array);
                    byte[] bytes2 = Convert.FromBase64String(text);
                    text          = Encoding.UTF8.GetString(bytes2);
                    AdsServerResponse adsServerResponse = JsonUtility.FromJson <AdsServerResponse>(text);
                    if (adsServerResponse != null)
                    {
                        if (adsServerResponse.ad_module_active == 0)
                        {
                            FMLogger.vAds("disable ads from config");
                            this.DisableAds();
                            this.config.DisableAds();
                            this.config.UpdateReward(AdConfig.FromRespone(adsServerResponse.rewarded_config, true), adsServerResponse.adUnit_rewarded);
                            this.SaveConfig(this.config);
                        }
                        else
                        {
                            AdConfig adConfig = AdConfig.FromResponse(adsServerResponse, this.isTablet);
                            this.SaveConfig(adConfig);
                            this.config.UpdateFsParamsFromServer(adConfig);
                            this.fsDisabled     = !this.config.FsIsOn();
                            this.bannerDisabled = !adConfig.BannerIsOn();
                        }
                    }
                }
                catch (Exception ex)
                {
                    FMLogger.vAds("config parse ex. msg:" + ex.Message);
                }
            }
            else
            {
                FMLogger.vAds("config  req server error. reschedule request");
                base.StartCoroutine(this.DelayAction(20f, new Action(this.GetServerConfig)));
            }
        });

        WebLoader.Instance.LoadText(task);
    }