Example #1
0
        public async Task StartAsync()
        {
            using (UnityWebRequestAsync request = ComponentFactory.Create <UnityWebRequestAsync>())
            {
                string versionUrl = GlobalConfigComponent.Instance.GlobalProto.GetUrl() + "StreamingAssets/" + "Version.txt";
                Log.Debug(versionUrl);
                await request.DownloadAsync(versionUrl);

                this.VersionConfig = MongoHelper.FromJson <VersionConfig>(request.Request.downloadHandler.text);
            }

            Log.Debug("WebVersion:\n" + MongoHelper.ToJson(this.VersionConfig));

            // 对比本地的Version.txt
            string versionPath = Path.Combine(PathHelper.AppHotfixResPath, "Version.txt");

            if (!File.Exists(versionPath))
            {
                foreach (FileVersionInfo versionInfo in this.VersionConfig.FileVersionInfos)
                {
                    if (versionInfo.File == "Version.txt")
                    {
                        continue;
                    }
                    this.bundles.Enqueue(versionInfo.File);
                    this.TotalSize += versionInfo.Size;
                }
            }
            else
            {
                VersionConfig localVersionConfig = MongoHelper.FromJson <VersionConfig>(File.ReadAllText(versionPath));
                Log.Debug("LocalVersion:\n" + MongoHelper.ToJson(localVersionConfig));
                // 先删除服务器端没有的ab
                foreach (FileVersionInfo fileVersionInfo in localVersionConfig.FileVersionInfos)
                {
                    if (this.VersionConfig.FileInfoDict.ContainsKey(fileVersionInfo.File))
                    {
                        continue;
                    }
                    string abPath = Path.Combine(PathHelper.AppHotfixResPath, fileVersionInfo.File);
                    File.Delete(abPath);
                }

                // 再下载
                foreach (FileVersionInfo fileVersionInfo in this.VersionConfig.FileVersionInfos)
                {
                    FileVersionInfo localVersionInfo;
                    if (localVersionConfig.FileInfoDict.TryGetValue(fileVersionInfo.File, out localVersionInfo))
                    {
                        if (fileVersionInfo.MD5 == localVersionInfo.MD5)
                        {
                            continue;
                        }
                    }

                    if (fileVersionInfo.File == "Version.txt")
                    {
                        continue;
                    }

                    this.bundles.Enqueue(fileVersionInfo.File);
                    this.TotalSize += fileVersionInfo.Size;
                }
            }

            if (this.bundles.Count == 0)
            {
                return;
            }

            Log.Debug($"need download bundles: {this.bundles.ToList().ListToString()}");
            await this.WaitAsync();
        }
Example #2
0
 public static string ToJson(object obj)
 {
     return(MongoHelper.ToJson(obj));
 }
        public void Awake()
        {
            string s = File.ReadAllText("./ClientConfig.txt");

            this.Config = MongoHelper.FromJson <ClientConfig>(s);
        }
Example #4
0
 public static T FromJson <T>(string str)
 {
     return(MongoHelper.FromJson <T>(str));
 }
Example #5
0
 public static object FromJson(Type type, string str)
 {
     return(MongoHelper.FromJson(type, str));
 }
 public object DeserializeFrom(Type type, string str)
 {
     return(MongoHelper.FromJson(type, str));
 }
Example #7
0
 public object DeserializeFrom(Type type, byte[] bytes, int index, int count)
 {
     return(MongoHelper.FromBson(type, bytes, index, count));
 }
Example #8
0
 public override string ToString()
 {
     return(MongoHelper.ToJson(this));
 }
Example #9
0
 public object Clone()
 {
     return(MongoHelper.FromJson(this.GetType(), this.ToString()));
 }
Example #10
0
 public byte[] SerializeToByteArray(object obj)
 {
     return(MongoHelper.ToBson(obj));
 }
Example #11
0
 public object Clone()
 {
     return(MongoHelper.FromBson(this.GetType(), this.ToBson()));
 }
Example #12
0
 public T DeserializeFrom <T>(string str)
 {
     return(MongoHelper.FromJson <T>(str));
 }
Example #13
0
 public T DeserializeFrom <T>(byte[] bytes, int index, int count)
 {
     return(MongoHelper.FromBson <T>(bytes, index, count));
 }
Example #14
0
 public T DeserializeFrom <T>(byte[] bytes)
 {
     return(MongoHelper.FromBson <T>(bytes));
 }
 public string SerializeToText(object obj)
 {
     return(MongoHelper.ToJson(obj));
 }
Example #16
0
        private void Awake()
        {
            string s = File.ReadAllText("../Config/StartConfig/ClientConfig.txt");

            this.Config = MongoHelper.FromJson <StartConfig>(s);
        }
 public T DeserializeFrom <T>(string str) where T : SerializerBinary
 {
     return(MongoHelper.FromJson <T>(str));
 }
Example #18
0
 public object Clone()
 {
     return(MongoHelper.FromJson <StartConfig>(MongoHelper.ToJson(this)));
 }
Example #19
0
 public object Clone()
 {
     return(MongoHelper.FromBson <Options>(this.ToBson()));
 }
Example #20
0
 public object DeserializeFrom(Type type, byte[] bytes)
 {
     return(MongoHelper.FromBson(type, bytes));
 }