Пример #1
0
    void DownloadFileFromServer(int version, string fileName, string localPath, Action <string> callback)
    {
        //string md5FileName = _serverRootXML.SelectSingleNode("/root/Version").Attributes["md5url"].Value;
        networkUrl = URLs.GetVersionPath(version, fileName);
        var t = new Thread(LogIpAddressAndMobileIP);

        t.Start();
        Logger.Log("[DownloadFileFromServer] " + networkUrl);

        SetupUI.instance.SetHint("更新" + fileName + "版本至 " + version);
        StartCoroutine(LoadFileForm(networkUrl,
                                    (p) =>
        {
            SetupUI.instance.SetProgress(p);
            Logger.Log("program updating ..." + p);
        },
                                    (www, errorInfo) =>
        {
            if (www == null || !string.IsNullOrEmpty(errorInfo))
            {
                Logger.Error("download file bytes empty error:" + errorInfo);

                PluginMsgAction.Instance.ShowMsgBox("download " + networkUrl + " error:" + errorInfo, "确定", "取消", () =>
                {
                    PluginMsgAction.Instance.HideMsgBox();
                    Application.Quit();
                },
                                                    () =>
                {
                    Application.Quit();
                });

                return;
            }
            errorInfo = SaveFile(www.bytes, localPath, true);
            callback.Invoke(errorInfo);
        }));
    }