Beispiel #1
0
        /// <summary>
        /// 检查是否有资源需要更新;
        /// </summary>
        public static void CheckResVersion()
        {
            if (!m_isDownLoadOpen)
            {
                return;
            }

            foreach (KeyValuePair <string, DownLoadAssetInfo> kv in m_dicDownLoadInfo)
            {
                if (kv.Value == null)
                {
                    Debug.LogError("WWWDownLoaderConfig CheckResVersion, kv.Value can not be null. Key : " + kv.Key);
                    continue;
                }

                bool hasContains = true;
                foreach (KeyValuePair <string, KeyValuePairConfigHelper> kvLocal in m_dicLocalResVerReader)
                {
                    KeyValuePairConfigHelper gtHelper = kvLocal.Value;
                    if (gtHelper != null)
                    {
                        if (gtHelper.CheckHasResVersion(kv.Key))
                        {
                            string strMD5 = gtHelper.GetNodeMD5(kv.Key);                     //本地没有配置,返回为空;
                            if (kv.Value.m_strMD5.Equals(strMD5))                            //如果MD5不相同,就是需要更新替换的资源;
                            {
                                hasContains = false;
                            }
                        }
                    }
                    else
                    {
                        Debug.LogError("WWWDownLoaderConfig CheckResVersion, gtHelper can not be null. " + kv.Key);
                    }
                }
                if (hasContains)
                {
                    if (!m_dicUpdateRes.ContainsKey(kv.Key))
                    {
                        m_dicUpdateRes.Add(kv.Key, kv.Value.m_strMD5);
                    }
                    else
                    {
                        // 有一种可能触发的情况: CheckResVersion有2次 一次版本文件的Check,一次Res内容的Check.
                        // 如果 第一次版本文件的流程结束后,kv.Key没有更新(从Dic中移除),就会出现这个Log.
                        // 表示,这个版本文件 没有更新成功。 or 服务器的版本文件中存在这个 版本.json 但是客户端代码里的 json列表里面没有这个文件;
                        Debug.LogError("WWWDownLoaderConfig CheckResVersion, m_dicUpdateRes ContainsKey " + kv.Key);
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 解析客户端资源MD5配置;
        /// </summary>
        static public void ParseClientResourcesConfig(string outParentPath, string fileName)
        {
            if (!m_isDownLoadOpen)
            {
                return;
            }

            m_strClientJsonPath = outParentPath + fileName;
            KeyValuePairConfigHelper kvpHelper = new KeyValuePairConfigHelper();

            kvpHelper.LoadConfigFromFile(m_strClientJsonPath);
            if (!m_dicLocalResVerReader.ContainsKey(fileName))
            {
                m_dicLocalResVerReader.Add(fileName, kvpHelper);
            }
            else
            {
                Debug.LogError("WWWDownLoaderConfig ParseClientResourcesConfig, Same key : " + fileName);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 新下载文件完成,需要保存MD5配置;
        /// </summary>
        static public void SaveNewAssetMD5(string strName, string strMD5, string strBelongConfig)
        {
            KeyValuePairConfigHelper kvpHelper = null;

            if (m_dicLocalResVerReader.ContainsKey(strBelongConfig))
            {
                kvpHelper = m_dicLocalResVerReader[strBelongConfig];
            }
            else
            {
                kvpHelper = new KeyValuePairConfigHelper();
                kvpHelper.LoadConfigFromFile(CommonValue.ClientVerDir + strBelongConfig);
                m_dicLocalResVerReader.Add(strBelongConfig, kvpHelper);
            }
            if (kvpHelper == null)
            {
                Debug.LogError("WWWDownLoaderConfig SaveNewAssetMD5,kvpHelper must be new first!");
                return;
            }

            kvpHelper.SetNodeValue(strName, strMD5, null);
        }
Beispiel #4
0
        /// <summary>
        /// 解析客户端资源MD5配置;
        /// </summary>
        static public void ParseServerResourcesConfig(string strBelongConfig, string strData)
        {
            if (string.IsNullOrEmpty(strData))
            {
                Debug.LogError("WWWDownLoaderManage ParseServerResourcesConfig,Config Data can not be null");
                return;
            }

            KeyValuePairConfigHelper kvpHelper = new KeyValuePairConfigHelper();

            kvpHelper.LoadConfig(strData, CommonValue.ResDir + strBelongConfig);

            if (kvpHelper.SelectHeadNode())
            {
                while (true)
                {
                    DownLoadAssetInfo downLoadInfo = new DownLoadAssetInfo();
                    downLoadInfo.m_strName         = kvpHelper.GetNodeKey();
                    downLoadInfo.m_strMD5          = kvpHelper.GetNodeMD5();
                    downLoadInfo.m_nSize           = Convert.ToInt64(kvpHelper.GetNodeSize());
                    downLoadInfo.m_strBelongConfig = strBelongConfig;

                    if (m_dicDownLoadInfo.ContainsKey(downLoadInfo.m_strName))
                    {
                        Debug.LogError("WWWDownLoaderManage ParseServerJson,Same Key : " + downLoadInfo.m_strName);
                    }
                    else
                    {
                        m_dicDownLoadInfo.Add(downLoadInfo.m_strName, downLoadInfo);
                    }

                    if (!kvpHelper.SelectNextNode())
                    {
                        break;//结束读取循环;
                    }
                }
            }
        }