예제 #1
0
        /// <summary>
        ///     Loads resources file.
        /// </summary>
        private static void LoadResources()
        {
            ResourceManager.ContentUrlList        = new LogicArrayList <string>();
            ResourceManager.ChronosContentUrlList = new LogicArrayList <string>();
            ResourceManager.AppStoreUrlList       = new LogicArrayList <string>();

            string resourceFile = WebManager.DownloadConfigString("/res/resources.json");

            if (resourceFile != null)
            {
                LogicJSONObject jsonObject          = (LogicJSONObject)LogicJSONParser.Parse(resourceFile);
                LogicJSONArray  contentArray        = jsonObject.GetJSONArray("content");
                LogicJSONArray  chronosContentArray = jsonObject.GetJSONArray("chronosContent");
                LogicJSONArray  appStoreArray       = jsonObject.GetJSONArray("appstore");

                for (int i = 0; i < contentArray.Size(); i++)
                {
                    ResourceManager.ContentUrlList.Add(contentArray.GetJSONString(i).GetStringValue());
                }

                for (int i = 0; i < chronosContentArray.Size(); i++)
                {
                    ResourceManager.ChronosContentUrlList.Add(chronosContentArray.GetJSONString(i).GetStringValue());
                }

                for (int i = 0; i < appStoreArray.Size(); i++)
                {
                    ResourceManager.AppStoreUrlList.Add(appStoreArray.GetJSONString(i).GetStringValue());
                }
            }
            else
            {
                Debugger.Error("ResourceManager::loadResources resources.json not exist");
            }
        }
예제 #2
0
        /// <summary>
        ///     Downloads last assets.
        /// </summary>
        private static void DownloadLastAssets(LogicJSONObject currentFingerprint)
        {
            string lastSha = WebManager.DownloadConfigString("/sha");

            if (lastSha != null)
            {
                string json = WebManager.DownloadAssetString(lastSha, "fingerprint.json");

                if (json != null)
                {
                    ResourceManager.DownloadAssets(currentFingerprint, json);
                }
            }
        }
예제 #3
0
        /// <summary>
        ///     Verifies the version of assets.
        /// </summary>
        private static void VerifyAssets()
        {
            string json = ResourceManager.LoadAssetFile("fingerprint.json");

            if (json != null)
            {
                LogicJSONObject jsonObject = (LogicJSONObject)LogicJSONParser.Parse(json);
                LogicJSONString shaObject  = jsonObject.GetJSONString("sha");

                string lastSha = WebManager.DownloadConfigString("/sha");

                if (shaObject.GetStringValue() != lastSha)
                {
                    ResourceManager.DownloadLastAssets(jsonObject);
                }
            }
            else
            {
                ResourceManager.DownloadLastAssets(null);
            }
        }
예제 #4
0
        /// <summary>
        ///     Loads the service config.
        /// </summary>
        private static void LoadConfig()
        {
            string json = WebManager.DownloadConfigString("/core/services.json");

            if (json != null)
            {
                LogicJSONObject jsonObject = (LogicJSONObject)LogicJSONParser.Parse(json);

                LogicJSONString versionObject = jsonObject.GetJSONString("version");

                if (versionObject != null)
                {
                    ServiceSettings._serviceVersion = versionObject.GetStringValue();
                }

                LogicJSONObject nodeObject = jsonObject.GetJSONObject("node");

                if (nodeObject != null)
                {
                    LogicJSONArray proxyArray = nodeObject.GetJSONArray("proxy");

                    if (proxyArray != null)
                    {
                        ServiceSettings._serviceIPs[1] = new string[proxyArray.Size()];

                        for (int i = 0; i < proxyArray.Size(); i++)
                        {
                            ServiceSettings._serviceIPs[1][i] = proxyArray.GetJSONString(i).GetStringValue();
                        }
                    }

                    LogicJSONArray accountArray = nodeObject.GetJSONArray("account");

                    if (accountArray != null)
                    {
                        ServiceSettings._serviceIPs[2] = new string[accountArray.Size()];

                        for (int i = 0; i < accountArray.Size(); i++)
                        {
                            ServiceSettings._serviceIPs[2][i] = accountArray.GetJSONString(i).GetStringValue();
                        }
                    }

                    LogicJSONArray globalArray = nodeObject.GetJSONArray("global_chat");

                    if (globalArray != null)
                    {
                        ServiceSettings._serviceIPs[6] = new string[globalArray.Size()];

                        for (int i = 0; i < globalArray.Size(); i++)
                        {
                            ServiceSettings._serviceIPs[6][i] = globalArray.GetJSONString(i).GetStringValue();
                        }
                    }

                    LogicJSONArray avatarArray = nodeObject.GetJSONArray("avatar");

                    if (avatarArray != null)
                    {
                        ServiceSettings._serviceIPs[9] = new string[avatarArray.Size()];

                        for (int i = 0; i < avatarArray.Size(); i++)
                        {
                            ServiceSettings._serviceIPs[9][i] = avatarArray.GetJSONString(i).GetStringValue();
                        }
                    }

                    LogicJSONArray homeArray = nodeObject.GetJSONArray("zone");

                    if (homeArray != null)
                    {
                        ServiceSettings._serviceIPs[10] = new string[homeArray.Size()];

                        for (int i = 0; i < homeArray.Size(); i++)
                        {
                            ServiceSettings._serviceIPs[10][i] = homeArray.GetJSONString(i).GetStringValue();
                        }
                    }

                    LogicJSONArray allianceArray = nodeObject.GetJSONArray("party");

                    if (allianceArray != null)
                    {
                        ServiceSettings._serviceIPs[11] = new string[allianceArray.Size()];

                        for (int i = 0; i < allianceArray.Size(); i++)
                        {
                            ServiceSettings._serviceIPs[11][i] = allianceArray.GetJSONString(i).GetStringValue();
                        }
                    }

                    LogicJSONArray leagueArray = nodeObject.GetJSONArray("ranking");

                    if (leagueArray != null)
                    {
                        ServiceSettings._serviceIPs[13] = new string[leagueArray.Size()];

                        for (int i = 0; i < leagueArray.Size(); i++)
                        {
                            ServiceSettings._serviceIPs[13][i] = leagueArray.GetJSONString(i).GetStringValue();
                        }
                    }

                    LogicJSONArray battleArray = nodeObject.GetJSONArray("battle");

                    if (battleArray != null)
                    {
                        ServiceSettings._serviceIPs[27] = new string[battleArray.Size()];

                        for (int i = 0; i < battleArray.Size(); i++)
                        {
                            ServiceSettings._serviceIPs[27][i] = battleArray.GetJSONString(i).GetStringValue();
                        }
                    }
                }

                LogicJSONObject databaseObject = jsonObject.GetJSONObject("database");

                if (databaseObject != null)
                {
                    LogicJSONArray urls = databaseObject.GetJSONArray("urls");

                    if (urls != null)
                    {
                        ServiceSettings._databaseUrls = new string[urls.Size()];

                        for (int i = 0; i < urls.Size(); i++)
                        {
                            ServiceSettings._databaseUrls[i] = urls.GetJSONString(i).GetStringValue();
                        }
                    }

                    ServiceSettings._databaseUser     = LogicJSONHelper.GetJSONString(databaseObject, "user");
                    ServiceSettings._databasePassword = LogicJSONHelper.GetJSONString(databaseObject, "pass");
                }
            }
        }