/// <summary>
        /// To Lua
        /// </summary>
        /// <param name="sessionName"></param>
        /// <param name="firstZipName"></param>
        /// <param name="fileListFileName"></param>
        /// <param name="firstZipUrl"></param>
        /// <param name="fileListFileUrl"></param>
        /// <param name="netFileRootUrl"></param>
        /// <param name="handler"></param>
        public void BeginSessionLua(string sessionName, string firstZipName, string fileListFileName, string firstZipUrl, string fileListFileUrl, string netFileRootUrl, IFSSessionDelegate handler)
        {
            if (string.IsNullOrEmpty(sessionName))
            {
                JW.Common.Log.LogE("IFS Service BeginSessionLua Error SessionName");
                return;
            }
            IFSSession ss = new IFSSession();
            ss.Name = sessionName;
            ss.FirstZipName = firstZipName;
            ss.FileListFileName = fileListFileName;
            ss.SessionHandler = handler;
            //
            ss.FirstZipURL = firstZipUrl;
            ss.FileListFileUrl = fileListFileUrl;
            ss.NetFileRootUrl = netFileRootUrl;
            //
            for (int i = _sessionProcessors.Count - 1; i >= 0; --i)
            {
                if (_sessionProcessors[i].Name.Equals(sessionName))
                {
                    JW.Common.Log.LogE("Repeat Session:" + sessionName);
                    return;
                }
            }

            IFSSessionProcessor pp = IFSSessionProcessor.Create(ss);
            if (pp != null)
            {
                pp.gameObject.transform.parent = this.transform;
                _sessionProcessors.Add(pp);
                pp.BeginSession();
            }
        }
 /// <summary>
 /// 开始事务
 /// </summary>
 /// <param name="ss"></param>
 public void BeginSession(IFSSession ss)
 {
     if (ss==null)
     {
         JW.Common.Log.LogE("IFS Service BeginSession nil Session");
         return;
     }
     //
     for (int i = _sessionProcessors.Count - 1; i >= 0; --i)
     {
         if (_sessionProcessors[i].Name.Equals(ss.Name))
         {
             JW.Common.Log.LogE("Repeat Session:" + ss.Name);
             return;
         }
     }
     //
     IFSSessionProcessor pp = IFSSessionProcessor.Create(ss);
     if (pp != null)
     {
         pp.gameObject.transform.parent = this.transform;
         _sessionProcessors.Add(pp);
         pp.BeginSession();
     }
 }
 public void UnInit()
 {
     StopAllCoroutines();
     //
     _curSession    = null;
     _localFileList = null;
     _netFileList   = null;
     _diffFileList  = null;
     //移动解压终止
     if (_cachedDownloader != null)
     {
         _cachedDownloader.Dispose();
         _cachedDownloader = null;
     }
     //终止文件列表下载
     if (_diffDownloadInfo != null)
     {
         foreach (KeyValuePair <uint, string> kvp in _diffDownloadInfo)
         {
             HttpService.GetInstance().UnRegisteFileHttpDownload(kvp.Key);
         }
         _diffDownloadInfo.Clear();
         _diffDownloadInfo = null;
     }
     _errorCnt = 0;
     IsDone    = false;
 }
        public static IFSSessionProcessor Create(IFSSession session)
        {
            IFSSessionProcessor ret = null;
            GameObject          go  = new GameObject("IFSSessionProcessor_" + session.Name);

            ret = go.ExtAddComponent <IFSSessionProcessor>(true);
            ret.Init(session);
            return(ret);
        }
        public void StopSession()
        {
            StopCoroutine("StartSession");
            //回收
            if (_netFileList != null)
            {
                _netFileList = null;
            }
            if (_localFileList != null)
            {
                _localFileList = null;
            }
            if (_diffFileList != null)
            {
                _diffFileList = null;
            }

            //移动解压终止
            if (_cachedDownloader != null)
            {
                _cachedDownloader.Dispose();
                _cachedDownloader = null;
            }
            //终止文件列表下载
            if (_diffDownloadInfo != null)
            {
                foreach (KeyValuePair <uint, string> kvp in _diffDownloadInfo)
                {
                    HttpService.GetInstance().UnRegisteFileHttpDownload(kvp.Key);
                }
                _diffDownloadInfo.Clear();
                _diffDownloadInfo = null;
            }

            if (_curSession == null)
            {
                JW.Common.Log.LogE("IFS Service Stop No Run");
                return;
            }
            else
            {
                _curSession.SessionHandler = null;
                //删除标记文件
                string ifsDir    = JW.Res.FileUtil.GetIFSExtractPath();
                string localPath = JW.Res.FileUtil.CombinePath(ifsDir, _curSession.FileListFileName);
                JW.Res.FileUtil.DeleteFile(localPath);
                _curSession = null;
            }
            //
            IsDone = true;
        }
        IEnumerator StartSession()
        {
            CallSessionHandler(IFSState.Start, 0);
            yield return(null);

            //---------首次下载或者移动----------------
            yield return(StartCoroutine(DoFirstMoveOrDownload()));

            //
            yield return(new WaitForEndOfFrame());

            //--------------本地文件检测--------------
            CallSessionHandler(IFSState.LocalFileListInit, 0);
            yield return(StartCoroutine(DoLocalFileListCheck()));

            //-----------获取网络文件列表
            CallSessionHandler(IFSState.NetFileListDownload, 0);
            yield return(StartCoroutine(DoDownloadNetFileList()));

            //------生成差异-------------
            CallSessionHandler(IFSState.LocalDiffNetFileList, 0);
            yield return(StartCoroutine(DoDiffNetFileList()));

            //下载更新文件
            CallSessionHandler(IFSState.DownloadDiffFileListBegin, 0);
            yield return(StartCoroutine(DoDownloadDiffFileList()));

            //
            yield return(new WaitForEndOfFrame());

            //写最新的服务器文件列表到本地
            CallSessionHandler(IFSState.GenerateLastFileList, 1.0f);
            yield return(StartCoroutine(DoWriteSvrFileListToLocal()));

            //GC 下
            System.GC.Collect();
            UnityEngine.Resources.UnloadUnusedAssets();
            yield return(null);

            //Over
            CallSessionHandler(IFSState.Over, 1.0f);
            //
            _curSession.SessionHandler = null;
            _curSession = null;
            yield return(null);

            IsDone = true;
        }
 public void Init(IFSSession ss)
 {
     _curSession = ss;
     IsDone      = false;
 }