private void HotUpdate() { if (this.bootupStatus == PandoraImpl.BootupStatus.kReadConfigDone) { Logger.DEBUG(string.Empty); this.resMgr.Init(); this.resMgr.DeleteRedundantFiles(this.dependencyAll); List <PandoraImpl.DownloadASTask> list = new List <PandoraImpl.DownloadASTask>(); using (List <PandoraImpl.DownloadASTask> .Enumerator enumerator = this.pendingDownloadASTasks.GetEnumerator()) { while (enumerator.MoveNext()) { PandoraImpl.DownloadASTask current = enumerator.get_Current(); if (!this.dependencyAll.Contains(current.name)) { list.Add(current); } } } using (List <PandoraImpl.DownloadASTask> .Enumerator enumerator2 = list.GetEnumerator()) { while (enumerator2.MoveNext()) { PandoraImpl.DownloadASTask current2 = enumerator2.get_Current(); this.pendingDownloadASTasks.Remove(current2); } } list.Clear(); this.bootupStatus = PandoraImpl.BootupStatus.kLocalLoading; } if (this.bootupStatus == PandoraImpl.BootupStatus.kLocalLoading) { Logger.DEBUG(string.Empty); while (this.dependencyAll.get_Count() > 0) { if (this.isDependencyLoading) { Logger.DEBUG("waiting local loading!"); return; } string first = this.dependencyAll.get_Item(0); string text = string.Empty; PandoraImpl.DownloadASTask taskOfDependency = null; using (List <PandoraImpl.DownloadASTask> .Enumerator enumerator3 = this.pendingDownloadASTasks.GetEnumerator()) { while (enumerator3.MoveNext()) { PandoraImpl.DownloadASTask current3 = enumerator3.get_Current(); if (first == current3.name) { taskOfDependency = current3; text = current3.md5; break; } } } Logger.DEBUG("first=" + first + " md5=" + text); if (this.resMgr.IsFileExistsInCache(first, text) || (!this.resMgr.IsFileExistsInCache(first, text) && taskOfDependency == null)) { Logger.DEBUG("first=" + first + " md5=" + text); Action <bool> action = delegate(bool status) { this.isDependencyLoading = false; if (status) { Logger.DEBUG(first + " loaded"); using (Dictionary <string, List <PandoraImpl.FileState> > .Enumerator enumerator6 = this.dependencyInfos.GetEnumerator()) { while (enumerator6.MoveNext()) { KeyValuePair <string, List <PandoraImpl.FileState> > current6 = enumerator6.get_Current(); using (List <PandoraImpl.FileState> .Enumerator enumerator7 = current6.get_Value().GetEnumerator()) { while (enumerator7.MoveNext()) { PandoraImpl.FileState current7 = enumerator7.get_Current(); if (current7.name == first) { current7.isReady = true; } } } } } this.TryDoLua(first); this.dependencyAll.RemoveAt(0); if (taskOfDependency != null) { this.pendingDownloadASTasks.Remove(taskOfDependency); } } else { Logger.ERROR(string.Empty); this.dependencyAll.RemoveAt(0); this.resMgr.DeleteFile(first); } }; if (Utils.IsLuaAssetBundle(first)) { Logger.DEBUG(string.Empty); this.isDependencyLoading = true; base.StartCoroutine(this.resMgr.LoadLuaAssetBundle(first, action)); } else { Logger.DEBUG(string.Empty); action.Invoke(true); } } else { this.resMgr.DeleteFile(first); this.dependencyAll.RemoveAt(0); } } if (this.dependencyAll.get_Count() == 0) { Logger.DEBUG(string.Empty); this.bootupStatus = PandoraImpl.BootupStatus.kLocalLoadDone; } } if (this.bootupStatus == PandoraImpl.BootupStatus.kLocalLoadDone || this.bootupStatus == PandoraImpl.BootupStatus.kDownloading) { this.bootupStatus = PandoraImpl.BootupStatus.kDownloading; int num = 0; List <PandoraImpl.DownloadASTask> list2 = new List <PandoraImpl.DownloadASTask>(this.pendingDownloadASTasks); using (List <PandoraImpl.DownloadASTask> .Enumerator enumerator4 = list2.GetEnumerator()) { while (enumerator4.MoveNext()) { PandoraImpl.DownloadASTask current4 = enumerator4.get_Current(); if (current4.isDownloading) { num++; } } } using (List <PandoraImpl.DownloadASTask> .Enumerator enumerator5 = list2.GetEnumerator()) { while (enumerator5.MoveNext()) { PandoraImpl.DownloadASTask current5 = enumerator5.get_Current(); PandoraImpl.DownloadASTask task = current5; int num2 = Utils.NowSeconds() - task.lastDownloadTime; if (!task.isDownloading && num2 > this.retryDownloadASInterval) { Logger.DEBUG(string.Concat(new object[] { "task.url=", task.url, " task.size=", task.size, " task.md5=", task.md5 })); Action <int, Dictionary <string, object> > action2 = delegate(int downloadRet, Dictionary <string, object> result) { Logger.DEBUG(string.Concat(new object[] { "task.url=", task.url, " task.size=", task.size, " task.md5=", task.md5 })); if (downloadRet == 0) { Logger.DEBUG(string.Empty); this.resMgr.AddCacheFileMeta(task.name, task.size, task.md5); Action <bool> action3 = delegate(bool status) { task.isDownloading = false; this.pendingDownloadASTasks.Remove(task); if (status) { Logger.DEBUG(string.Empty); using (Dictionary <string, List <PandoraImpl.FileState> > .Enumerator enumerator6 = this.dependencyInfos.GetEnumerator()) { while (enumerator6.MoveNext()) { KeyValuePair <string, List <PandoraImpl.FileState> > current6 = enumerator6.get_Current(); using (List <PandoraImpl.FileState> .Enumerator enumerator7 = current6.get_Value().GetEnumerator()) { while (enumerator7.MoveNext()) { PandoraImpl.FileState current7 = enumerator7.get_Current(); if (current7.name == task.name) { current7.isReady = true; } } } } } this.TryDoLua(task.name); this.pendingDownloadASTasks.Remove(task); } else { Logger.ERROR(task.name + " load to mem failed!"); this.resMgr.DeleteFile(task.name); } }; if (Utils.IsLuaAssetBundle(task.name)) { this.StartCoroutine(this.resMgr.LoadLuaAssetBundle(task.name, action3)); } else { action3.Invoke(true); } } else { Logger.ERROR(string.Empty); task.isDownloading = false; } }; task.isDownloading = true; num++; task.lastDownloadTime = Utils.NowSeconds(); string destFile = Pandora.Instance.GetCachePath() + "/" + Path.GetFileName(task.url); this.netLogic.AddDownload(task.url, task.size, task.md5, destFile, 0, action2); if (num >= this.maxDownloadingTaskNum) { break; } } } } if (this.pendingDownloadASTasks.get_Count() == 0) { Logger.DEBUG(string.Empty); this.bootupStatus = PandoraImpl.BootupStatus.kDownloadDone; } } }
public static bool ParseConfigData(Dictionary <string, object> content, ref Dictionary <string, object> result) { Logger.DEBUG(string.Empty); try { int num = 0; if (content.ContainsKey("id")) { num = Convert.ToInt32(content.get_Item("id")); } int num2 = -1; if (content.ContainsKey("totalSwitch")) { num2 = Convert.ToInt32(content.get_Item("totalSwitch")); } bool result2; if (num2 == 0) { result.set_Item("ruleId", num); result.set_Item("totalSwitch", false); result2 = true; return(result2); } if (num2 != 1) { result2 = false; return(result2); } Dictionary <string, bool> dictionary = new Dictionary <string, bool>(); if (content.ContainsKey("function_switch")) { string text = content.get_Item("function_switch") as string; string[] array = text.Split(new char[] { ',' }); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text2 = array2[i]; string[] array3 = text2.Split(new char[] { ':' }); if (array3.Length == 2) { string text3 = array3[0]; int num3 = Convert.ToInt32(array3[1]); dictionary.set_Item(text3, num3 == 1); } } } int num4 = 0; if (content.ContainsKey("isDebug")) { num4 = Convert.ToInt32(content.get_Item("isDebug")); } int num5 = 1; if (content.ContainsKey("isNetLog")) { num5 = Convert.ToInt32(content.get_Item("isNetLog")); } string text4 = string.Empty; string text5 = string.Empty; string text6 = string.Empty; ushort num6 = 0; if (content.ContainsKey("ip")) { text4 = Convert.ToString(content.get_Item("ip")); } if (content.ContainsKey("port")) { num6 = Convert.ToUInt16(content.get_Item("port")); } if (content.ContainsKey("cap_ip1")) { text5 = Convert.ToString(content.get_Item("cap_ip1")); } if (content.ContainsKey("cap_ip2")) { text6 = Convert.ToString(content.get_Item("cap_ip2")); } if ((text4.get_Length() == 0 && text5.get_Length() == 0 && text6.get_Length() == 0) || num6 == 0) { result2 = false; return(result2); } int num7 = -1; Dictionary <string, List <PandoraImpl.FileState> > dictionary2 = new Dictionary <string, List <PandoraImpl.FileState> >(); List <string> list = new List <string>(); HashSet <string> hashSet = new HashSet <string>(); if (content.ContainsKey("dependency")) { string text7 = content.get_Item("dependency") as string; string[] array4 = text7.Split(new char[] { '|' }); num7 = array4.Length; string[] array5 = array4; for (int j = 0; j < array5.Length; j++) { string text8 = array5[j]; string[] array6 = text8.Split(new char[] { ':' }); if (array6.Length == 2) { string text9 = array6[0]; string text10 = array6[1]; string[] array7 = text10.Split(new char[] { ',' }); List <PandoraImpl.FileState> list2 = new List <PandoraImpl.FileState>(); string[] array8 = array7; for (int k = 0; k < array8.Length; k++) { string text11 = array8[k]; list2.Add(new PandoraImpl.FileState { name = text11 }); if (!hashSet.Contains(text11)) { list.Add(text11); hashSet.Add(text11); } } dictionary2.set_Item(text9, list2); } } } if (num7 <= 0 || num7 != dictionary2.get_Count()) { result2 = false; return(result2); } int num8 = -1; List <PandoraImpl.DownloadASTask> list3 = new List <PandoraImpl.DownloadASTask>(); if (content.ContainsKey("sourcelist")) { Dictionary <string, object> dictionary3 = content.get_Item("sourcelist") as Dictionary <string, object>; if (dictionary3 != null && dictionary3.ContainsKey("count") && dictionary3.ContainsKey("list")) { int num9 = Convert.ToInt32(dictionary3.get_Item("count")); List <object> list4 = dictionary3.get_Item("list") as List <object>; if (num9 == list4.get_Count()) { num8 = num9; HashSet <string> hashSet2 = new HashSet <string>(); using (List <object> .Enumerator enumerator = list4.GetEnumerator()) { while (enumerator.MoveNext()) { object current = enumerator.get_Current(); Dictionary <string, object> dictionary4 = current as Dictionary <string, object>; if (dictionary4.ContainsKey("url") && dictionary4.ContainsKey("luacmd5") && dictionary4.ContainsKey("size")) { PandoraImpl.DownloadASTask downloadASTask = new PandoraImpl.DownloadASTask(); downloadASTask.url = (dictionary4.get_Item("url") as string); downloadASTask.size = (int)((long)dictionary4.get_Item("size")); downloadASTask.md5 = (dictionary4.get_Item("luacmd5") as string); downloadASTask.name = Path.GetFileName(downloadASTask.url); if (downloadASTask.name != null && downloadASTask.name.get_Length() > 0 && downloadASTask.md5.get_Length() > 0 && downloadASTask.size > 0 && !hashSet2.Contains(downloadASTask.name)) { list3.Add(downloadASTask); hashSet2.Add(downloadASTask.name); } } } } } } else { num8 = 0; } } if (num8 < 0 || num8 != list3.get_Count()) { result2 = false; return(result2); } result.set_Item("ruleId", num); result.set_Item("totalSwitch", true); result.set_Item("isDebug", num4 == 1); result.set_Item("isNetLog", num5 == 1); result.set_Item("brokerHost", text4); result.set_Item("brokerPort", num6); result.set_Item("brokerAltIp1", text5); result.set_Item("brokerAltIp2", text6); result.set_Item("functionSwitches", dictionary); result.set_Item("dependencyInfos", dictionary2); result.set_Item("dependencyAll", list); result.set_Item("pendingDownloadASTasks", list3); result2 = true; return(result2); } catch (Exception ex) { Logger.ERROR(ex.get_StackTrace()); } return(true); }