少年修仙传客户端代码仓库
client_Wu Xijin
2018-08-22 0a858ed58b484a23d01a8232e151dd8efa145561
1621 IOS分包资源下载弹框,点击暂停游戏崩溃
2个文件已修改
58 ■■■■ 已修改文件
System/AssetVersion/InGameDownLoad.cs 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/AssetVersion/RemoteFile.cs 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/AssetVersion/InGameDownLoad.cs
@@ -16,8 +16,6 @@
    public bool inGameDownLoadAllow = false;
    public float progress {
        get {
            return Mathf.Clamp01((float)showDownLoadedSize / showTotalSize);
@@ -240,7 +238,6 @@
        }
    }
    int workingQueueMaxCount = 1;
    IEnumerator Co_StartDownLoad()
    {
@@ -249,18 +246,14 @@
        workingQueue.Clear();
        okCount = 0;
        var downLoadTasksQueues = new Queue<AssetVersion>();
        for (int i = 0; i < tasks.Count; i++)
        {
            var assetVersion = tasks[i];
            if (!assetVersion.localValid)
            {
                var remoteURL = StringUtility.Contact(VersionUtility.Instance.versionInfo.GetResourcesURL(VersionConfig.Get().branch), "/", assetVersion.relativePath);
                var localURL = StringUtility.Contact(ResourcesPath.Instance.ExternalStorePath, assetVersion.relativePath);
                var remoteFile = new RemoteFile();
                workingQueue.Add(remoteFile);
                remoteFile.Init(remoteURL, localURL, assetVersion, true);
                remoteFile.Begin(OnFileDownLoadCompleted);
                downLoadTasksQueues.Enqueue(assetVersion);
            }
            else
            {
@@ -270,6 +263,17 @@
        while (okCount < totalCount)
        {
            while (workingQueue.Count < 2 && downLoadTasksQueues.Count > 0)
            {
                var assetVersion = downLoadTasksQueues.Dequeue();
                var remoteURL = StringUtility.Contact(VersionUtility.Instance.versionInfo.GetResourcesURL(VersionConfig.Get().branch), "/", assetVersion.relativePath);
                var localURL = StringUtility.Contact(ResourcesPath.Instance.ExternalStorePath, assetVersion.relativePath);
                var remoteFile = new RemoteFile();
                workingQueue.Add(remoteFile);
                remoteFile.Init(remoteURL, localURL, assetVersion, true);
                remoteFile.Begin(OnFileDownLoadCompleted);
            }
            yield return null;
        }
@@ -307,6 +311,15 @@
    private void OnFileDownLoadCompleted(bool _ok, AssetVersion _assetVersion)
    {
        foreach (var remote in workingQueue)
        {
            if (remote.assetVersion == _assetVersion)
            {
                workingQueue.Remove(remote);
                break;
            }
        }
        if (_ok)
        {
            okCount++;
System/AssetVersion/RemoteFile.cs
@@ -72,7 +72,7 @@
        }
    }
    AssetVersion assetVersion;
    public AssetVersion assetVersion { get; private set; }
    protected string mRemoteFile;
    protected string localFile;
    bool speedLimit = false;
@@ -123,6 +123,7 @@
    public static void Prepare()
    {
        gDownloadIsRunningCount = 0;
        gStartTickcount = System.Environment.TickCount;
        TotalDownloadedSize = 0L;
        downloadSpeedRef = 0f;
@@ -153,7 +154,8 @@
        }
        stop = true;
        try
        {
        if (headRequest != null)
        {
            headRequest.Abort();
@@ -190,13 +192,19 @@
            inStream.Close();
            inStream = null;
        }
        }
        catch (Exception ex)
        {
            Debug.Log(ex);
        }
        finally
        {
        onCompleted = null;
        mHadError = false;
        if (state == State.Working)
        {
            gDownloadIsRunningCount--;
            }
        }
    }
@@ -324,7 +332,11 @@
                            headResponse.Close();
                            headResponse = null;
                        }
                        if (headRequest != null)
                        {
                        headRequest.Abort();
                            headRequest = null;
                        }
                    }
                }, headRequest);
@@ -373,7 +385,12 @@
        if (mHadError)
        {
            DebugEx.LogWarningFormat("获取远程文件{0} 信息失败!", mRemoteFile);
            if (headRequest != null)
            {
            headRequest.Abort();
                headRequest = null;
            }
            done = true;
            gDownloadIsRunningCount--;
            yield break;