예제 #1
0
        public List <KeyValuePair <string, byte[]> > LoadFiles(List <KeyValuePair <string, string> > fileFullNames)
        {
            Action action = null;

            this.Open();
            List <KeyValuePair <string, byte[]> > list = new List <KeyValuePair <string, byte[]> >();

            lock (m_locker)
            {
                foreach (KeyValuePair <string, string> pair in fileFullNames)
                {
                    string key = pair.Value.PathNormalize();
                    if ((this.m_fileStream != null) && this.m_fileIndexes.ContainsKey(key))
                    {
                        byte[] buffer = this.DoLoadFile(key);
                        list.Add(new KeyValuePair <string, byte[]>(pair.Key, buffer));
                    }
                    else
                    {
                        if (action == null)
                        {
                            action = delegate {
                                LoggerHelper.Error("File not exist in MogoFileSystem: " + this.FileFullName, true);
                            };
                        }
                        DriverLib.Invoke(action);
                    }
                }
            }
            return(list);
        }
예제 #2
0
 public void ModalCheckNetwork(Action check)
 {
     DriverLib.Invoke(() =>
     {
         //无网络的情况不判断了
         if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
         {
             //3G网络,弹窗口,确定下载还是退出
             System.Collections.Generic.Dictionary <int, DefaultLanguageData> languageData = DefaultUI.dataMap;
             ForwardLoadingMsgBoxLib.Instance.ShowMsgBox(languageData[6].content, languageData[7].content, languageData[5].content, (confirm) =>
             {
                 if (confirm)
                 {
                     ForwardLoadingMsgBoxLib.Instance.Hide();
                     check();
                 }
                 else
                 {
                     ForwardLoadingMsgBoxLib.Instance.Hide();
                     Application.Quit();
                 }
             });
         }
         else
         {
             check();
         }
     });
 }
예제 #3
0
    public void AsynDownLoadText(String url, Action <String> asynResult, Action OnError)
    {
        var u = GetRandomParasUrl(url);

        if (Application.platform == RuntimePlatform.WindowsWebPlayer || Application.platform == RuntimePlatform.WindowsEditor)
        {
            DownloadMgrForWeb.DownloadText(url, asynResult);
            return;
        }
        Action action = () =>
        {
            var result = DownLoadText(u);
            if (String.IsNullOrEmpty(result))
            {
                if (OnError != null)
                {
                    DriverLib.Invoke(OnError);
                }
            }
            else
            {
                if (asynResult != null)
                {
                    DriverLib.Invoke(() => { asynResult(result); });
                }
            }
        };

#if UNITY_IPHONE || !UNITY_WEBPLAYER
        action();
#else
        action.BeginInvoke(null, null);
#endif
    }
예제 #4
0
    public void AsynDownLoadText(String url, Action <String> asynResult, Action OnError)
    {
        //LoggerHelper.Debug ("DownloadMgr.AsynDownLoadText() url="+url);
        var    u      = url;
        Action action = () =>
        {
            var result = DownLoadText(u);
            if (String.IsNullOrEmpty(result))
            {
                if (OnError != null)
                {
                    DriverLib.Invoke(OnError);
                }
            }
            else
            {
                if (asynResult != null)
                {
                    DriverLib.Invoke(() => { asynResult(result); });
                }
            }
        };

        action.BeginInvoke(null, null);
    }
예제 #5
0
    //添加一个网络异常处理的功能,mycontinue跳过当前这个下载下一个
    static void HandleNetworkError(Exception e, Action mycontinue, Action again, Action finished = null)
    {
        LoggerHelper.Except(e);
        Action action = () =>
        {
            //LoggerHelper.Debug("webclient error:" + e.Message);
            if (e.Message.Contains("ConnectFailure") || //连接失败
                e.Message.Contains("NameResolutionFailure") || //域名解析失败
                e.Message.Contains("No route to host"))    //找不到主机
            {
                LoggerHelper.Error("-----------------Webclient ConnectFailure-------------");
                //异常时弹出网络设置对话框
                ShowMsgBoxForNetworkDisconnect(again, _showMsg ? ":" + e.Message : "");
            }
            else
            //(404) Not Found
            if (e.Message.Contains("(404) Not Found") || e.Message.Contains("403"))
            {
                LoggerHelper.Error("-----------------WebClient NotFount-------------");
                //抛出一个error,并且继续下载下一个
                //mycontinue();
                //服务器维护中,请稍后再试
                ShowMsgForServerMaintenance(again, _showMsg ? ":" + e.Message : "");
            }
            else
            //Disk full
            if (e.Message.Contains("Disk full"))
            {
                LoggerHelper.Error("-----------------WebClient Disk full-------------");
                ShowMsgBoxForDiskFull(again, _showMsg ? ":" + e.Message : "");
            }
            else
            //timed out
            if (e.Message.Contains("timed out") || e.Message.Contains("Error getting response stream"))
            {
                LoggerHelper.Error("-----------------WebClient timed out-------------");
                //again();
                ShowMsgForTimeout(again, _showMsg ? ":" + e.Message : "");
            }
            else
            //Sharing violation on path
            if (e.Message.Contains("Sharing violation on path"))
            {
                LoggerHelper.Error("-----------------WebClient Sharing violation on path-------------");
                again();
            }
            else
            {
                //LoggerHelper.Debug("-----------------WebClient myfinished-------------");
                //if (finished != null) finished();
                //again();
                ShowMsgForUnknown(again, _showMsg ? ":" + e.Message : "");
            }
        };

        DriverLib.Invoke(action);
    }
예제 #6
0
        public void FindSucc(string msg)
        {
            var action = new Action(() =>
            {
                LoggerHelper.Debug("=====================FindSucc:" + msg);
                m_isStop = true; //停止监听
                CloseServerFind();
                EventDispatcher.TriggerEvent <string>(FindServerEvent.FindServerSucc, msg);
            });

            DriverLib.Invoke(action);
        }
예제 #7
0
 /**服务器关闭回调**/
 private void closeCallback()
 {
     try
     {
         if (OnNetworkDisconnected != null)
         {
             DriverLib.Invoke(OnNetworkDisconnected);
         }
     }
     catch (Exception ex)
     {
         LoggerHelper.Except(ex, "服务器[" + ip + ":" + port + "]关闭回调出错!");
     }
 }
예제 #8
0
        public void TryConnetServer(object action)
        {
            List <string> ipList = GetAllLocalIp();
            bool          status = false;
            string        ip     = null;

            for (int i = 0; i < ipList.Count; i++)
            {
                if (m_isStop)
                {
                    break;
                }
                try
                {
                    TcpClient tcp = new TcpClient(ipList[i], PORT);
                    //tcp.GetStream();

                    status = true;
                    tcp.Close();
                    ip = ipList[i];
                    break;
                }
                catch (Exception ex)
                {
                    //LoggerHelper.Debug("===========fail:" + ipList[i]);
                    //LoggerHelper.Debug("======ex:" + ex);
                    status = false;
                }
            }
            CallBackDelegate cdb = action as CallBackDelegate;

            if (status)
            {
                LoggerHelper.Debug("====FindServer ok:" + ip);
                //cdb.Invoke(ip);
                DriverLib.Invoke(() => { cdb(ip); });
                //cdb(ip);
                //EventDispatcher.TriggerEvent<string>(FindServerEvent.FindServerSucc, ip);
            }
            else
            {
                LoggerHelper.Debug("====FindServer fail");
                DriverLib.Invoke(() => { cdb(ip); });
                //cdb(ip);
                //EventDispatcher.TriggerEvent<string>(FindServerEvent.FindServerSucc, ip);
            }
        }
예제 #9
0
    private void AsynDownloadApkNoExport(Action <int, int, string> taskProgress, string fileName, string url, string md5, Action <int, long, long> progress, Action finished, Action <Exception> error)
    {
        DownloadTask task = new DownloadTask {
            FileName      = fileName,
            Url           = url,
            Finished      = finished,
            Error         = error,
            TotalProgress = progress,
            MD5           = md5
        };

        LoggerHelper.Info("down load apk & md5: " + url + " " + md5, true);
        DownloadMgr.Instance.tasks = new List <DownloadTask> {
            task
        };
        DownloadMgr.Instance.TaskProgress = delegate(int total, int current, string filename) {
            if (taskProgress != null)
            {
                taskProgress(total, current, filename);
            }
        };
        DownloadMgr.Instance.AllDownloadFinished = delegate {
            DriverLib.Invoke(delegate {
                if (RuntimePlatform.IPhonePlayer == Application.platform)
                {
                    Action <bool> onClick = delegate(bool confirm) {
                        if (!confirm)
                        {
                            Application.Quit();
                        }
                    };
                    ForwardLoadingMsgBoxLib.Instance.ShowMsgBox(DefaultUI.dataMap[11].content, DefaultUI.dataMap[7].content, DefaultUI.dataMap[12].content, onClick);
                }
                else
                {
                    this.InstallApk(fileName);
                }
            });
            if (finished != null)
            {
                finished();
            }
            LoggerHelper.Debug("apk安装成功", true, 0);
        };
        DownloadMgr.Instance.CheckDownLoadList();
    }
예제 #10
0
        public override List <KeyValuePair <string, byte[]> > LoadFiles(List <KeyValuePair <string, string> > fileFullNames)
        {
            Open();
            List <KeyValuePair <string, byte[]> > result = new List <KeyValuePair <string, byte[]> >();

            lock (m_locker)
            {
                foreach (var fileFullName in fileFullNames)
                {
                    var path = fileFullName.Value.PathNormalize();
                    if (m_fileStream != null && m_fileIndexes.ContainsKey(path))
                    {
                        var fileData = DoLoadFile(path);
                        result.Add(new KeyValuePair <string, byte[]>(fileFullName.Key, fileData));
                    }
                    else
                    {
                        DriverLib.Invoke(() => { LoggerHelper.Error("File not exist in MogoFileSystem: " + FileFullName); });
                    }
                }
            }
            return(result);
        }
예제 #11
0
    private static void HandleNetworkError(Exception e, Action mycontinue, Action again, Action finished = null)
    {
        LoggerHelper.Except(e, null);
        Action action = delegate {
            if ((e.Message.Contains("ConnectFailure") || e.Message.Contains("NameResolutionFailure")) || e.Message.Contains("No route to host"))
            {
                LoggerHelper.Error("-----------------Webclient ConnectFailure-------------", true);
                ShowMsgBoxForNetworkDisconnect(again, ":" + e.Message);
            }
            else if (e.Message.Contains("(404) Not Found") || e.Message.Contains("403"))
            {
                LoggerHelper.Error("-----------------WebClient NotFount-------------", true);
                ShowMsgForServerMaintenance(again, ":" + e.Message);
            }
            else if (e.Message.Contains("Disk full"))
            {
                LoggerHelper.Error("-----------------WebClient Disk full-------------", true);
                ShowMsgBoxForDiskFull(again, ":" + e.Message);
            }
            else if (e.Message.Contains("timed out") || e.Message.Contains("Error getting response stream"))
            {
                LoggerHelper.Error("-----------------WebClient timed out-------------", true);
                ShowMsgForTimeout(again, ":" + e.Message);
            }
            else if (e.Message.Contains("Sharing violation on path"))
            {
                LoggerHelper.Error("-----------------WebClient Sharing violation on path-------------", true);
                again();
            }
            else
            {
                ShowMsgForUnknown(again, ":" + e.Message);
            }
        };

        DriverLib.Invoke(action);
    }
예제 #12
0
    public void AsynDownLoadText(string url, Action <string> asynResult, Action OnError)
    {
        string u = this.GetRandomParasUrl(url);

        delegate {
            Action action = null;
            string result = this.DownLoadText(u);
            if (string.IsNullOrEmpty(result))
            {
                if (OnError != null)
                {
                    DriverLib.Invoke(OnError);
                }
            }
            else if (asynResult != null)
            {
                if (action == null)
                {
                    action = () => asynResult(result);
                }
                DriverLib.Invoke(action);
            }
        }.BeginInvoke(null, null);
    }
예제 #13
0
        public static void LoadCfgInfo(Action <bool> callback)
        {
#if !UNITY_WEBPLAYER
            string cfgStr;
            if (File.Exists(CfgPath))
            {
                cfgStr = Utils.LoadFile(CfgPath);
                //CfgInfo = LoadXMLText<CfgInfo>(cfgStr);
                CfgInfoNew = LoadCfgInfoList(cfgStr);
                if (callback != null)
                {
                    DriverLib.Invoke(() => callback(CfgInfoNew != null && CfgInfoNew.Count > 0 ? true : false));
                }
            }
            else
            {
#endif
            var cfgUrl = Utils.LoadResource(Utils.GetFileNameWithoutExtention(CFG_FILE));
            LoggerHelper.Info("cfgUrl: " + cfgUrl);
            var programVerStr = "";
            var programVer    = Resources.Load(VERSION_URL_KEY) as TextAsset;
            if (programVer && !String.IsNullOrEmpty(programVer.text))
            {
                programVerStr = "V" + VersionManager.Instance.GetVersionInXML(programVer.text).ProgramVersion;
            }

            var s = Application.persistentDataPath.Split('/');
            //Debug.Log(s.Length);
            for (int i = s.Length - 1; i >= 0; i--)
            {
                //Debug.Log(s[i]);
                if (s[i] == "files" && i - 1 >= 0)
                {
                    BundleIdentifier = s[i - 1];
                    LoggerHelper.Info("bundleIdentifier: " + BundleIdentifier);
                    break;
                }
            }

            Action erraction = () =>
            {
                if (callback != null)
                {
                    DriverLib.Invoke(() => callback(false));
                }
            };
            Action <string> suaction = null;
            suaction = (res) =>
            {
                var parentinfo = LoadCfgInfoList(res);
                foreach (var pair in parentinfo)
                {
                    if (!CfgInfoNew.ContainsKey(pair.Key))
                    {
                        CfgInfoNew.Add(pair.Key, pair.Value);
                    }
                }
                if (!string.IsNullOrEmpty(BundleIdentifier) && parentinfo.ContainsKey(BundleIdentifier))//根据包名做特殊处理
                {
                    CfgInfoNew.Clear();
                    DownloadMgr.Instance.AsynDownLoadText(parentinfo[BundleIdentifier], suaction, erraction);
                }
                else if (parentinfo.ContainsKey(programVerStr))//根据版本做特殊处理
                {
                    CfgInfoNew.Clear();
                    DownloadMgr.Instance.AsynDownLoadText(parentinfo[programVerStr], suaction, erraction);
                }
                else if (parentinfo.ContainsKey(CFG_PARENT_KEY))
                {
                    DownloadMgr.Instance.AsynDownLoadText(parentinfo[CFG_PARENT_KEY], suaction, erraction);
                }
                else if (callback != null)
                {
                    DriverLib.Invoke(() => callback(CfgInfoNew != null && CfgInfoNew.Count > 0 ? true : false));
                }
            };
            DownloadMgr.Instance.AsynDownLoadText(cfgUrl, suaction, erraction);
#if !UNITY_WEBPLAYER
        }
#endif
        }
예제 #14
0
    private void AsynDownloadApk(Action <int, int, string> taskProgress, string fileName, string url, Action <int, long, long> progress, Action finished, Action <Exception> error)
    {
        var task = new DownloadTask
        {
            FileName      = fileName,
            Url           = url,
            Finished      = finished,
            Error         = error,
            TotalProgress = progress,
            MD5           = ServerVersion.ApkMd5
        };

        LoggerHelper.Info("down load apk & md5: " + url + " " + ServerVersion.ApkMd5);
        //LoggerHelper.Debug("APK保存的MD5值: " + ServerVersion.ApkMd5);
        var tasks = new List <DownloadTask> {
            task
        };

        DownloadMgr.Instance.tasks = tasks;
        //添加taskProgress的回调
        Action <int, int, string> TaskProgress = (total, current, filename) =>
        {
            if (taskProgress != null)
            {
                taskProgress(total, current, filename);
            }
        };

        DownloadMgr.Instance.TaskProgress = TaskProgress;
        StreamingAssetManager go = null;

        ResourceIndexInfo.Instance.Init(Application.streamingAssetsPath + "/ResourceIndexInfo.txt", () =>
        {
            LoggerHelper.Info("资源索引信息:" + ResourceIndexInfo.Instance.GetLeftFilePathes().Length);
            if (ResourceIndexInfo.Instance.GetLeftFilePathes().Length == 0)
            {
                go = new StreamingAssetManager();
                go.UpdateProgress = false;
                go.ApkFinished    = true;
            }
            else
            {
                //下载apk时导出资源
                go = new StreamingAssetManager {
                    UpdateProgress = false
                };
                go.AllFinished = () =>
                {
                    LoggerHelper.Debug("打开资源导出完成的标识11ApkFinished");
                    go.ApkFinished = true;
                };
            }
        });
        DownloadMgr.Instance.AllDownloadFinished = () =>
        {
            LoggerHelper.Info("APK download finish, wait for export finish:" + fileName);
            if (go != null)
            {
                go.UpdateProgress = true;
                LoggerHelper.Debug("打开导出进度显示:" + go.ApkFinished);
                //先判断资源导出是否完成,再安装apk,没完成则等待完成
                while (!go.ApkFinished)
                {
                    System.Threading.Thread.Sleep(500);
                }
                LoggerHelper.Info("APK and export download finish.");
                go = null;
            }
            DriverLib.Invoke(() =>
            {
#if UNITY_IPHONE
                Action <bool> InstallIpa = (confirm) =>
                {
                    if (confirm)
                    {
                        //IOSUtils.UpdateLoader(fileName);
                    }
                    else
                    {
                        Application.Quit();
                    }
                };
                ForwardLoadingMsgBoxLib.Instance.ShowMsgBox(DefaultUI.dataMap[11].content,
                                                            DefaultUI.dataMap[7].content,
                                                            DefaultUI.dataMap[12].content,
                                                            InstallIpa);
#else
                InstallApk(fileName);
#endif
            });
            if (finished != null)
            {
                finished();
            }
            LoggerHelper.Debug("apk安装成功");
        };
        var stopwatch = new System.Diagnostics.Stopwatch();
        stopwatch.Start();
        while (go == null)
        {
            System.Threading.Thread.Sleep(50);
            if (stopwatch.ElapsedMilliseconds > 3000)
            {
                break;
            }
            //LoggerHelper.Debug("阻塞直到StreamingAssetManager不为null或超时3秒");
        }
        stopwatch.Stop();
        //开始下载apk同时导出资源文件
        if (go != null && !go.ApkFinished)
        {
            LoggerHelper.Debug("apk下载同时导出资源");
            go.UpdateApkExport();
        }
        DownloadMgr.Instance.CheckDownLoadList();
    }
예제 #15
0
 public void ModalCheckNetwork(Action check, Action <Exception> error)
 {
     DriverLib.Invoke(delegate {
         Action <List <PackageInfo> > asynResult = null;
         Action onError = null;
         if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
         {
             if (asynResult == null)
             {
                 asynResult = delegate(List <PackageInfo> packageList) {
                     float num = 0f;
                     int count = 0;
                     if (packageList.Count != 0)
                     {
                         List <KeyValuePair <string, string> > list = new List <KeyValuePair <string, string> >();
                         foreach (PackageInfo info in packageList)
                         {
                             if ((info.LowVersion.Compare(this.LocalVersion.ResouceVersionInfo) >= 0) && (info.HighVersion.Compare(this.ServerVersion.ResouceVersionInfo) <= 0))
                             {
                                 list.Add(new KeyValuePair <string, string>(info.HighVersion.ToString(), info.Name));
                             }
                         }
                         if (list.Count != 0)
                         {
                             count = list.Count;
                             foreach (KeyValuePair <string, string> pair in list)
                             {
                                 string requestUriString = this.ServerVersion.PackageUrl + pair.Value;
                                 try
                                 {
                                     HttpWebRequest request   = (HttpWebRequest)WebRequest.Create(requestUriString);
                                     HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                                     num += response.ContentLength;
                                     response.Close();
                                     request.Abort();
                                 }
                                 catch (Exception exception)
                                 {
                                     error(exception);
                                 }
                             }
                         }
                     }
                     num /= 1048576f;
                     LoggerHelper.Debug("3G network", true, 0);
                     Dictionary <int, DefaultLanguageData> dataMap = DefaultUI.dataMap;
                     string content = string.Format(dataMap[5].content, count, string.Format("{0:0.00}", num));
                     ForwardLoadingMsgBoxLib.Instance.ShowMsgBox(dataMap[6].content, dataMap[7].content, content, delegate(bool confirm) {
                         if (confirm)
                         {
                             LoggerHelper.Debug("3G network confirm", true, 0);
                             ForwardLoadingMsgBoxLib.Instance.Hide();
                             check();
                         }
                         else
                         {
                             LoggerHelper.Debug("3G network cancel", true, 0);
                             ForwardLoadingMsgBoxLib.Instance.Hide();
                             Application.Quit();
                         }
                     });
                 };
             }
             if (onError == null)
             {
                 onError = () => error(new Exception("DownloadPackageInfoList error."));
             }
             Instance.GetUpdateDownloadPackageInfoList(asynResult, onError);
         }
         else
         {
             check();
         }
     });
 }
예제 #16
0
 void Awake()
 {
     m_instance = this;
 }
예제 #17
0
 void Awake()
 {
     m_instance = this;
 }
예제 #18
0
    private void AsynDownloadApkNoExport(Action <int, int, string> taskProgress, string fileName, string url, string md5, Action <int, long, long> progress, Action finished, Action <Exception> error)
    {
        var task = new DownloadTask
        {
            FileName      = fileName,
            Url           = url,
            Finished      = finished,
            Error         = error,
            TotalProgress = progress,
            MD5           = md5
        };

        LoggerHelper.Info("down load apk & md5: " + url + " " + md5);
        DownloadMgr.Instance.tasks = new List <DownloadTask> {
            task
        };;
        //添加taskProgress的回调
        DownloadMgr.Instance.TaskProgress = (total, current, filename) =>
        {
            if (taskProgress != null)
            {
                taskProgress(total, current, filename);
            }
        };
        DownloadMgr.Instance.AllDownloadFinished = () =>
        {
            DriverLib.Invoke(() =>
            {
                if (RuntimePlatform.IPhonePlayer == Application.platform)
                {
                    Action <bool> InstallIpa = (confirm) =>
                    {
                        if (confirm)
                        {
#if UNITY_IPHONE
                            //IOSPlugins.InstallIpa(fileName);
#endif
                        }
                        else
                        {
                            Application.Quit();
                        }
                    };
                    ForwardLoadingMsgBoxLib.Instance.ShowMsgBox(DefaultUI.dataMap[11].content,
                                                                DefaultUI.dataMap[7].content,
                                                                DefaultUI.dataMap[12].content,
                                                                InstallIpa);
                }
                else
                {
                    InstallApk(fileName);
                }
            });
            if (finished != null)
            {
                finished();
            }
            LoggerHelper.Debug("apk安装成功");
        };
        DownloadMgr.Instance.CheckDownLoadList();
    }
예제 #19
0
    private void AsynDownloadApk(Action <int, int, string> taskProgress, string fileName, string url, Action <int, long, long> progress, Action finished, Action <Exception> error)
    {
        DownloadTask task = new DownloadTask {
            FileName      = fileName,
            Url           = url,
            Finished      = finished,
            Error         = error,
            TotalProgress = progress,
            MD5           = this.ServerVersion.ApkMd5
        };

        LoggerHelper.Info("down load apk & md5: " + url + " " + this.ServerVersion.ApkMd5, true);
        List <DownloadTask> list = new List <DownloadTask> {
            task
        };

        DownloadMgr.Instance.tasks = list;
        Action <int, int, string> action = delegate(int total, int current, string filename) {
            if (taskProgress != null)
            {
                taskProgress(total, current, filename);
            }
        };

        DownloadMgr.Instance.TaskProgress = action;
        StreamingAssetManager go = null;

        ResourceIndexInfo.Instance.Init(Application.get_streamingAssetsPath() + "/ResourceIndexInfo.txt", delegate {
            Action action = null;
            LoggerHelper.Info("资源索引信息:" + ResourceIndexInfo.Instance.GetLeftFilePathes().Length, true);
            if (ResourceIndexInfo.Instance.GetLeftFilePathes().Length == 0)
            {
                go = new StreamingAssetManager {
                    UpdateProgress = false,
                    ApkFinished    = true
                };
            }
            else
            {
                go = new StreamingAssetManager {
                    UpdateProgress = false
                };
                if (action == null)
                {
                    action = delegate {
                        LoggerHelper.Debug("打开资源导出完成的标识11ApkFinished", true, 0);
                        go.ApkFinished = true;
                    };
                }
                go.AllFinished = action;
            }
        }, null);
        DownloadMgr.Instance.AllDownloadFinished = delegate {
            LoggerHelper.Info("APK download finish, wait for export finish:" + fileName, true);
            if (go != null)
            {
                go.UpdateProgress = true;
                LoggerHelper.Debug("打开导出进度显示:" + go.ApkFinished, true, 0);
                while (!go.ApkFinished)
                {
                    Thread.Sleep(500);
                }
                LoggerHelper.Info("APK and export download finish.", true);
                go = null;
            }
            DriverLib.Invoke(() => this.InstallApk(fileName));
            if (finished != null)
            {
                finished();
            }
            LoggerHelper.Debug("apk安装成功", true, 0);
        };
        Stopwatch stopwatch = new Stopwatch();

        stopwatch.Start();
        while (go == null)
        {
            Thread.Sleep(50);
            if (stopwatch.ElapsedMilliseconds > 0xbb8L)
            {
                break;
            }
        }
        stopwatch.Stop();
        if (!((go == null) || go.ApkFinished))
        {
            LoggerHelper.Debug("apk下载同时导出资源", true, 0);
            go.UpdateApkExport();
        }
        DownloadMgr.Instance.CheckDownLoadList();
    }
예제 #20
0
 private void Awake()
 {
     m_instance = this;
 }
예제 #21
0
        public static void LoadCfgInfo(Action <bool> callback)
        {
            Action action  = null;
            Action action2 = null;

            if (File.Exists(CfgPath))
            {
                CfgInfoNew = LoadCfgInfoList(Utils.LoadFile(CfgPath));
                if (callback != null)
                {
                    if (action == null)
                    {
                        action = () => callback((CfgInfoNew != null) && (CfgInfoNew.Count > 0));
                    }
                    DriverLib.Invoke(action);
                }
            }
            else
            {
                string    url           = Utils.LoadResource(Utils.GetFileNameWithoutExtention("cfg.xml", '/'));
                string    programVerStr = "";
                TextAsset asset         = Resources.Load("version") as TextAsset;
                if (!((asset == null) || string.IsNullOrEmpty(asset.text)))
                {
                    programVerStr = "V" + VersionManager.Instance.GetVersionInXML(asset.text).ProgramVersion;
                }
                if (action2 == null)
                {
                    action2 = delegate {
                        if (callback != null)
                        {
                            DriverLib.Invoke(() => callback(false));
                        }
                    };
                }
                Action          erraction = action2;
                Action <string> suaction  = null;
                suaction = delegate(string res) {
                    Dictionary <string, string> dictionary = LoadCfgInfoList(res);
                    foreach (KeyValuePair <string, string> pair in dictionary)
                    {
                        if (!CfgInfoNew.ContainsKey(pair.Key))
                        {
                            CfgInfoNew.Add(pair.Key, pair.Value);
                        }
                    }
                    if (dictionary.ContainsKey(programVerStr))
                    {
                        CfgInfoNew.Clear();
                        DownloadMgr.Instance.AsynDownLoadText(dictionary[programVerStr], suaction, erraction);
                    }
                    else if (dictionary.ContainsKey("parent"))
                    {
                        DownloadMgr.Instance.AsynDownLoadText(dictionary["parent"], suaction, erraction);
                    }
                    else if (callback != null)
                    {
                        DriverLib.Invoke(() => callback((CfgInfoNew != null) && (CfgInfoNew.Count > 0)));
                    }
                };
                DownloadMgr.Instance.AsynDownLoadText(url, suaction, erraction);
            }
        }