//-------------------------------------------------------------------------
    public void launchAutoPatcher(AutoPatcherConfig cfg)
    {
        // 设置自动更新参数配置,并检查参数有效性
        AutoPatcherConfig.RemoteVersionInfoUrl = cfg.RemoteVersionInfoUrl;
        if (string.IsNullOrEmpty(AutoPatcherConfig.RemoteVersionInfoUrl))
        {
            EbLog.Error("ClientAutoPatcher.launchAutoPatcher() AutoPatcherConfig.ServerUrlPrefix is Null!");
        }

        // 启动自动更新
        StepGetRemoteVersionInfo = true;
    }
    }                              // 完成自动更新

    //-------------------------------------------------------------------------
    public override void init()
    {
        EbLog.Note("ClientAutoPatcher.init()");

        StepGetRemoteVersionInfo = false;
        StepIsNeedBundlePatcher  = false;
        StepBundlePatcher        = false;
        StepIsNeedDataPatcher    = false;
        StepDataPatcher          = false;
        StepFinished             = false;

        AutoPatcherConfig      = new AutoPatcherConfig();
        VersionInfo            = new VersionInfo(AutoPatcherPath.combinePersistentDataPath("/DataFileList.txt"));
        mMapNeedDeleteAsset    = new Dictionary <string, string>();
        mMapSameAsset          = new Dictionary <string, string>();
        mQueueAlreadyLoadAsset = new Queue <string>();
    }
示例#3
0
    //-------------------------------------------------------------------------

    //-------------------------------------------------------------------------
    public override void init()
    {
        EbLog.Note("ClientSampleAutoPatcher.init()");

        EntityMgr.getDefaultEventPublisher().addHandler(Entity);

        AutoPatcherConfig autopatcher_cfg = new AutoPatcherConfig();

        autopatcher_cfg.RemoteVersionInfoUrl = "https://www.cragon.cn/download/Cragon/SampleAutoPatcher/VersionInfo.xml";

        var et_autopatcher = EntityMgr.createEntity <EtAutoPatcher>(null, Entity);
        var co_autopatcher = et_autopatcher.getComponent <ClientAutoPatcher <DefAutoPatcher> >();

        co_autopatcher.OnAutoPatcherGetServerVersionCfg =
            () =>
        {
            //UiMbLoading loading = UiMgr.Instance.createUi<UiMbLoading>(_eUiLayer.Loading);
            //loading.setTips("检测版本中");

            EbLog.Note("请求获取版本信息");
        };

        co_autopatcher.OnAutoPatcherGetServerVersionCfgResult =
            (r, error) =>
        {
            //UiMbLoading loading = UiMgr.Instance.createUi<UiMbLoading>(_eUiLayer.Loading);
            //loading.setTips("下载版本信息失败::Error::" + mServerVersionWWW.error);

            if (r == AutoPatcherResult.Success)
            {
                EbLog.Note("获取版本信息成功");
            }
            else
            {
                EbLog.Note("获取版本信息失败! Error=" + error);
            }
        };

        co_autopatcher.OnAutoPatcherIsNeedBundlePatcher =
            (is_need, local_bundle_version, remote_bundle_version) =>
        {
            if (!is_need)
            {
                //UiMgr.Instance.destroyCurrentUi<UiMbLoading>();
                EbLog.Note("Bundle版本相同,无需更新");
            }
            else
            {
                //UiMbLoading loading = UiMgr.Instance.createUi<UiMbLoading>(_eUiLayer.Loading);
                //loading.setTips("更新版本");
                //UiMbUpdate update = UiMgr.Instance.createUi<UiMbUpdate>(_eUiLayer.Loading);
                //update.setUpdateInfo("更新版本," + mVersionConfig.LocalVersionConfig.bundle_version + "版本到" + mVersionConfig.RemoteVersionConfig.bundle_version + "版本,是否更新?", _updateBundle, _cancelUpdate);

                string info = string.Format("Bundle版本不同,从{0}更新到{1}", local_bundle_version, remote_bundle_version);
                EbLog.Note(info);
            }
        };

        co_autopatcher.OnAutoPatcherIsNeedDataPatcher =
            (is_need, local_data_version, remote_data_version) =>
        {
            if (!is_need)
            {
                //UiMgr.Instance.destroyCurrentUi<UiMbLoading>();
                EbLog.Note("Data版本相同,无需更新");
            }
            else
            {
                //UiMbLoading loading = UiMgr.Instance.createUi<UiMbLoading>(_eUiLayer.Loading);
                //loading.setTips("更新数据");
                //UiMbUpdate update = UiMgr.Instance.createUi<UiMbUpdate>(_eUiLayer.Loading);
                //update.setUpdateInfo("更新数据," + mVersionConfig.LocalVersionConfig.data_version + "版本到" + mVersionConfig.RemoteVersionConfig.data_version + "版本,是否更新?", _updateData, _cancelUpdate);

                string info = string.Format("Data版本不同,从{0}更新到{1}", local_data_version, remote_data_version);
                EbLog.Note(info);
            }
        };

        co_autopatcher.OnAutoPatcherGetRemoteDataFileList =
            () =>
        {
            //UiMgr.Instance.destroyCurrentUi<UiMbUpdate>();
            //UiMbLoading loading = UiMgr.Instance.createUi<UiMbLoading>(_eUiLayer.Loading);
            //loading.setTips("更新数据中");

            EbLog.Note("请求获取数据文件列表");
        };

        co_autopatcher.OnAutoPatcherGetRemoteDataFileListResult =
            (r, error) =>
        {
            //UiMbLoading loading = UiMgr.Instance.createUi<UiMbLoading>(_eUiLayer.Loading);
            //loading.setLoadProgress(mUpdateDataWWW.progress, "更新数据错误 Error::" + mUpdateDataWWW.error);

            if (r == AutoPatcherResult.Success)
            {
                EbLog.Note("获取数据文件列表成功");
            }
            else
            {
                EbLog.Note("获取数据文件列表失败! Error=" + error);
            }
        };


        co_autopatcher.OnAutoPatcherDataPatcher =
            (info) =>
        {
            //UiMbLoading loading = UiMgr.Instance.createUi<UiMbLoading>(_eUiLayer.Loading);
            //loading.setLoadProgress(progress, msg);
            //EbLog.Note(msg + "   " + progress);

            EbLog.Note(info);
        };

        co_autopatcher.OnAutoPatcherFinished =
            () =>
        {
            EbLog.Note("自动更新结束");

            //public OnAutoPatcherFinished OnAutoPatcherFinished { get; set; }
            //CoApp.BundleVersion = mCheckVersion.mVersionConfig.LocalVersionConfig.bundle_version;
            //CoApp.DataVersion = mCheckVersion.mVersionConfig.LocalVersionConfig.data_version;

            //// 创建EtLogin
            //EntityMgr.createEntity<EtLogin>(null, CoApp.Entity);
            EntityMgr.destroyEntity(et_autopatcher);
        };

        co_autopatcher.launchAutoPatcher(autopatcher_cfg);
    }
示例#4
0
        //-------------------------------------------------------------------------
        public override void init()
        {
            EbLog.Note("ClientLaunch.init()");

            EntityMgr.getDefaultEventPublisher().addHandler(Entity);

            Entity et_app = EntityMgr.findFirstEntityByType <EtApp>();

            CoApp = et_app.getComponent <ClientApp <DefApp> >();

            AutoPatcherConfig autopatcher_cfg = new AutoPatcherConfig();

            autopatcher_cfg.RemoteVersionInfoUrl = MbMain.Instance.ClientConfig.RemoteVersionInfoUrl;

            var et_autopatcher = EntityMgr.createEntity <EtAutoPatcher>(null, Entity);
            var co_autopatcher = et_autopatcher.getComponent <ClientAutoPatcher <DefAutoPatcher> >();

            UiLoading ui_loading = UiMgr.Instance.createUi <UiLoading>("Loading", "Loading");

            ui_loading.OnFinished = () =>
            {
                // 创建EtLogin
                EntityMgr.createEntity <EtLogin>(null, CoApp.Entity);
                EntityMgr.destroyEntity(et_autopatcher);
            };

            co_autopatcher.OnAutoPatcherGetServerVersionCfg =
                () =>
            {
                ui_loading.setTip("请求获取版本信息");
            };

            co_autopatcher.OnAutoPatcherGetServerVersionCfgResult =
                (r, error) =>
            {
                if (r == AutoPatcherResult.Success)
                {
                    ui_loading.setTip("获取版本信息成功");
                }
                else
                {
                    ui_loading.setTip("获取版本信息失败! Error=" + error);
                }
            };

            co_autopatcher.OnAutoPatcherIsNeedBundlePatcher =
                (is_need, local_bundle_version, remote_bundle_version) =>
            {
                if (!is_need)
                {
                    ui_loading.setTip("Bundle版本相同,无需更新");
                }
                else
                {
                    ui_loading.setTip("更新Bundle");

                    string info = string.Format("Bundle版本不同,从{0}更新到{1}", local_bundle_version, remote_bundle_version);
                    //UiMbUpdate update = UiMgr.Instance.createUi<UiMbUpdate>(_eUiLayer.Waiting);
                    //Action delOk = () => { co_autopatcher.confirmPatcherBundle(); };
                    //Action delCancel = () => { Application.Quit(); };
                    //update.setUpdateInfo(info, delOk, delCancel);
                }
            };

            co_autopatcher.OnAutoPatcherIsNeedDataPatcher =
                (is_need, local_data_version, remote_data_version) =>
            {
                if (!is_need)
                {
                    ui_loading.setTip("Data版本相同,无需更新");
                }
                else
                {
                    //ui_loading.setTips("更新数据");

                    string info = string.Format("Data版本不同,从{0}更新到{1}", local_data_version, remote_data_version);
                    //UiMbUpdate update = UiMgr.Instance.createUi<UiMbUpdate>(_eUiLayer.Waiting);
                    //Action delOk = () => { co_autopatcher.confirmPatcherData(); };
                    //Action delCancel = () => { Application.Quit(); };
                    //update.setUpdateInfo(info, delOk, delCancel);
                }
            };

            co_autopatcher.OnAutoPatcherGetRemoteDataFileList =
                () =>
            {
                ui_loading.setTip("请求获取数据文件列表");
            };

            co_autopatcher.OnAutoPatcherGetRemoteDataFileListResult =
                (r, error) =>
            {
                if (r == AutoPatcherResult.Success)
                {
                    ui_loading.setTip("获取数据文件列表成功");
                }
                else
                {
                    ui_loading.setTip("获取数据文件列表失败! Error=" + error);
                }
            };

            co_autopatcher.OnAutoPatcherDataPatcher =
                (info) =>
            {
                ui_loading.setTip(info);
            };

            co_autopatcher.OnAutoPatcherFinished =
                () =>
            {
                ui_loading.setTip("自动更新结束");

                CoApp.BundleVersion = co_autopatcher.VersionInfo.LocalBundleVersion;
                CoApp.DataVersion   = co_autopatcher.VersionInfo.LocalVersionInfo.data_version;

                // 创建EtLogin
                EntityMgr.createEntity <EtLogin>(null, CoApp.Entity);
                EntityMgr.destroyEntity(et_autopatcher);
            };


            //co_autopatcher.launchAutoPatcher(autopatcher_cfg);
        }