Ejemplo n.º 1
0
        public void Bootup()
        {
            Logger.DEBUG(string.Empty);
            Action <int, Dictionary <string, object> > action = delegate(int status, Dictionary <string, object> content)
            {
                Logger.DEBUG(string.Empty);
                Dictionary <string, object> dictionary = new Dictionary <string, object>();
                if (status == 0 && Utils.ParseConfigData(content, ref dictionary))
                {
                    Logger.DEBUG(string.Empty);
                    this.bootupStatus = PandoraImpl.BootupStatus.kReadConfigDone;
                    this.ruleId       = (int)dictionary.get_Item("ruleId");
                    this.totalSwitch  = (bool)dictionary.get_Item("totalSwitch");
                    if (this.totalSwitch)
                    {
                        this.functionSwitches       = (dictionary.get_Item("functionSwitches") as Dictionary <string, bool>);
                        this.isDebug                = (bool)dictionary.get_Item("isDebug");
                        this.isNetLog               = (bool)dictionary.get_Item("isNetLog");
                        this.brokerHost             = (dictionary.get_Item("brokerHost") as string);
                        this.brokerPort             = (ushort)dictionary.get_Item("brokerPort");
                        this.brokerAltIp1           = (dictionary.get_Item("brokerAltIp1") as string);
                        this.brokerAltIp2           = (dictionary.get_Item("brokerAltIp2") as string);
                        this.dependencyInfos        = (dictionary.get_Item("dependencyInfos") as Dictionary <string, List <PandoraImpl.FileState> >);
                        this.dependencyAll          = (dictionary.get_Item("dependencyAll") as List <string>);
                        this.pendingDownloadASTasks = (dictionary.get_Item("pendingDownloadASTasks") as List <PandoraImpl.DownloadASTask>);
                        this.netLogic.SetBroker(this.brokerPort, this.brokerHost, this.brokerAltIp1, this.brokerAltIp2);
                    }
                }
                else
                {
                    Logger.DEBUG(string.Empty);
                    this.bootupStatus = PandoraImpl.BootupStatus.kReadConfigFailed;
                }
            };

            this.bootupStatus = PandoraImpl.BootupStatus.kReadingConfig;
            this.netLogic.GetRemoteConfig(action);
        }
 public void LogOut()
 {
     Logger.DEBUG(string.Empty);
     try
     {
         Utils.ResetCacheVersion();
         this.luaMgrInited = false;
         this.CloseAllPanel();
         this.netLogic.Logout();
         this.resMgr.Logout();
         this.luaMgr.Destroy();
         LuaScriptMgr.ResetStaticVars();
         this.luaMgr         = new LuaScriptMgr();
         this.lastReBootTime = -1;
         this.bootupStatus   = PandoraImpl.BootupStatus.kInitial;
         base.StopAllCoroutines();
         this.ruleId                  = 0;
         this.totalSwitch             = false;
         this.isDebug                 = false;
         this.isNetLog                = true;
         this.brokerHost              = string.Empty;
         this.brokerPort              = 0;
         this.brokerAltIp1            = string.Empty;
         this.brokerAltIp2            = string.Empty;
         this.functionSwitches        = new Dictionary <string, bool>();
         this.dependencyInfos         = new Dictionary <string, List <PandoraImpl.FileState> >();
         this.dependencyAll           = new List <string>();
         this.isDependencyLoading     = false;
         this.pendingDownloadASTasks  = new List <PandoraImpl.DownloadASTask>();
         this.showImgTasks            = new Dictionary <string, List <PandoraImpl.ShowImgTask> >();
         this.executedLuaAssetBundles = new HashSet <string>();
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_Message() + ":" + ex.get_StackTrace());
     }
 }
Ejemplo n.º 3
0
 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;
         }
     }
 }