Ejemplo n.º 1
0
        private void SyncRemoteBundlemap(Action syncRemoteBundlemapCallback)
        {
            string serverBundleMapInPersistentPath = Path.Combine(PathResolver.ApplicationPersistentDataPath, SysConf.SERVER_SQLITE_BUNDLE_MAP);

            if (File.Exists(serverBundleMapInPersistentPath))
            {
                this.m_remoteBundleIndicesMap = new BundleIndicesMap(serverBundleMapInPersistentPath);
                string localRemoteBundlemapIdentify = m_remoteBundleIndicesMap.GetBundleMapInfo(BundleIndicesMap.BundleMapKey.BUNDLEMAP_IDENTIFY);
                ResourceModule.Instance.DownloadBufferFromServer(SysConf.SQLITE_BUNDLE_MAP_HASH, (serverBundlemapHash) =>
                {
                    string latestBundlemapIdentify = Encoding.Default.GetString(serverBundlemapHash);
                    if (latestBundlemapIdentify == localRemoteBundlemapIdentify)
                    {
                        syncRemoteBundlemapCallback();
                    }
                    else
                    {
                        this.m_remoteBundleIndicesMap.Dispose();
                        DownloadRemoteBundleMap(syncRemoteBundlemapCallback);
                    }
                }, (bundlemap) =>
                {
                    SyncRemoteBundlemap(syncRemoteBundlemapCallback);
                });
            }
            else
            {
                DownloadRemoteBundleMap(syncRemoteBundlemapCallback);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 加载Bundlemap
        /// </summary>
        /// <param name="onLoad"></param>
        internal void LoadSQLiteBundleMap(Action onLoad = null)
        {
            SQLiteBundlemapLoader.Instance.LoadBundleMap(path =>
            {
                bundleMapLocal = new BundleIndicesMap(path);

                this.BundleMapAdapter = new BundleIndicesMapAdapter(bundleMapLocal);

                HasInitialized = true;

                onLoad?.Invoke();
            });
        }
Ejemplo n.º 3
0
        private void DownloadRemoteBundleMap(Action callback)
        {
            ResourceModule.Instance.DownloadBufferFromServer(SysConf.SQLITE_BUNDLE_MAP, (bundleMapBuffer) =>
            {
                string serverBundleMapInPersistentPath = Path.Combine(PathResolver.ApplicationPersistentDataPath, SysConf.SERVER_SQLITE_BUNDLE_MAP);
                EngineFileUtil.WriteBytesToFile(serverBundleMapInPersistentPath, bundleMapBuffer);

                this.m_remoteBundleIndicesMap = new BundleIndicesMap(serverBundleMapInPersistentPath);

                callback();
            }, (remoteBundleMap) =>
            {
                DownloadRemoteBundleMap(callback);
            });
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Bundlemap比对
        /// </summary>
        /// <param name="dstDbConnection"></param>
        /// <returns></returns>
        public BundleMapDiffResult Diff(SQLiteConnection dstDbConnection, bool closeDstDbConnection = true)
        {
            BundleMapDiffResult diffResult = new BundleMapDiffResult();

            //diffResult.AppendBundleIndexList = new List<BundleIndexItemInfo>();
            diffResult.DirtyBundleIndexList = new List <BundleIndexItemInfo>();

            Dictionary <string, BundleIndexItemInfo> currentAllBundleIndexDict = GetAllBundleIndexItemList().ToDictionary(bundleMapInfo => bundleMapInfo.BundleName);

            BundleIndicesMap           dstBundleIndicesMap   = new BundleIndicesMap(dstDbConnection);
            List <BundleIndexItemInfo> dstAllBundleIndexList = dstBundleIndicesMap.GetAllBundleIndexItemList();

            for (int i = 0; i < dstAllBundleIndexList.Count; ++i)
            {
                BundleIndexItemInfo dstBundleIndexItem = dstAllBundleIndexList[i];
                string dstBundleHash = dstBundleIndexItem.BundleHash;
                string dstBundleName = dstBundleIndexItem.BundleName;

                BundleIndexItemInfo existBundleIndexItem;
                if (currentAllBundleIndexDict.TryGetValue(dstBundleName, out existBundleIndexItem))
                {
                    if (existBundleIndexItem.BundleHash != dstBundleHash)
                    {
                        diffResult.DirtyBundleIndexList.Add(dstBundleIndexItem);
                    }

                    currentAllBundleIndexDict.Remove(dstBundleName);
                }
                else
                {
                    diffResult.AddAppendBundleItemInfo(dstBundleIndexItem);
                }
            }

            List <BundleIndexItemInfo> obsoletedBundleList = currentAllBundleIndexDict.Values.ToList();

            diffResult.ObsoleteBundleIndexList = obsoletedBundleList;

            if (closeDstDbConnection)
            {
                dstDbConnection.Dispose();
            }

            return(diffResult);
        }
Ejemplo n.º 5
0
        private IEnumerator SyncBundleMapToPersistentPath(Action <string> callback)
        {
            //检查localBundlemap是否是之前安装包的
            string buildinBundlemapHashPath = WWWUtil.GetStreamingAssetsPath("bundlemap.hash");
            WWW    www = new WWW(buildinBundlemapHashPath);

            yield return(www);

            string buildinBundlemapSha = www.text;

            www.Dispose();

            string bundlemapInPersistenPath = Path.Combine(PathResolver.ApplicationPersistentDataPath, SysConf.SQLITE_BUNDLE_MAP);

            if (File.Exists(bundlemapInPersistenPath))
            {
                BundleIndicesMap bundleMapInPersistent = new BundleIndicesMap(bundlemapInPersistenPath);
                string           localBundleIdentify   = bundleMapInPersistent.GetBundleMapInfo(BundleIndicesMap.BundleMapKey.BUNDLEMAP_IDENTIFY);
                bundleMapInPersistent.Dispose();

                if (localBundleIdentify == buildinBundlemapSha)
                {
                    callback(bundlemapInPersistenPath);
                    yield break;
                }
                else
                {
                    SyncBuildinBundlemap();
                    callback(bundlemapInPersistenPath);
                }
            }

            else
            {
                SyncBuildinBundlemap();
                callback(bundlemapInPersistenPath);
            }
        }
Ejemplo n.º 6
0
 public BundleIndicesMapAdapter(BundleIndicesMap bundlemap)
 {
     this.m_bundlemapHolder = bundlemap;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 对比两个Bundlemap的不同
 /// </summary>
 /// <param name="otherBundleIndicesMap"></param>
 /// <returns></returns>
 public BundleMapDiffResult Diff(BundleIndicesMap otherBundleIndicesMap)
 {
     return(Diff(otherBundleIndicesMap.BundleIndicesMapConn, false));
 }