Exemplo n.º 1
0
    public bool StartDownload(string path, bool bLoop = false)
    {
        string item = Path.GetFileName(path);

        if (!File.Exists(DirectoryPath + item))
        {
            DownLoadALLData downLoadData = new DownLoadALLData();
            downLoadData.bWget = true;
            downLoadData.bLoop = bLoop;
            //downLoadData.serverList = servers;

            downLoadData.item    = item;
            downLoadData.strFile = path;
            //downLoadData.data = data;
            m_listTempLoad.Add(downLoadData);
            m_nTotalCount += 1;
            //bStartLoading = false;
            return(true);
        }
        else
        {
            Debug.LogWarning("不需要下载");
            return(false);
        }
    }
Exemplo n.º 2
0
 public void CreateFile(string path, byte[] bytes, Delegate reback = null, DownLoadALLData _data = null)
 {
     //         int index = path.LastIndexOf("/");
     //         Directory.CreateDirectory(path.Substring(0, index));
     //         FileStream fstream = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None, bytes.Length, true);
     //         AsyncState asyncState = new AsyncState { fs = fstream, buffer = bytes, callback = reback, data = _data };
     //         //IAsyncResult asyncResult = fstream.BeginWrite(bytes, 0, bytes.Length, EndWriteCallback, asyncState);
     //         fstream.BeginWrite(bytes, 0, bytes.Length, EndWriteCallback, asyncState);
 }
Exemplo n.º 3
0
    public bool StartDownload(string path, bool bLoop = false)
    {
        DownLoadALLData downLoadData = new DownLoadALLData();

        downLoadData.bWget = true;
        downLoadData.bLoop = bLoop;
        //downLoadData.serverList = servers;
        string item = Path.GetFileName(path);

        downLoadData.item    = item;
        downLoadData.strFile = path;
        //downLoadData.data = data;
        m_listTempLoad.Add(downLoadData);
        m_nTotalCount += 1;
        //bStartLoading = false;
        return(true);
    }
Exemplo n.º 4
0
    public void RestartCurUrl()
    {
        data.www = null;
        string strUrl = data.strWgetUrl;

        if (!data.bWget || strUrl == "")
        {
            m_nCurCount += 1;
            if (data.failBack != null)
            {
                data.failBack.Method.Invoke(data.failBack.Target, new object[] { data.strFile, data.item });
            }
            data = null;
            return;
        }

        data.www = new WWW(strUrl);
        data.www.threadPriority = ThreadPriority.Low;
        m_fCurProcess           = 0;
    }
Exemplo n.º 5
0
    public void UpdateDownload()
    {
        //Debug.LogError("开始下载把");
        if (m_listTempLoad != null && m_listTempLoad.Count > 0)
        {
            int nCount = m_listTempLoad.Count;
            for (int i = 0; i < nCount; i++)
            {
                //Debug.Log("Temp   "+m_listTempLoad[i].strWgetUrl);
                DownLoadALLData dataTemp = m_listTempLoad[i];
                m_listLoad.Add(dataTemp);
            }
            m_listTempLoad.Clear();
        }

        if (!bStartLoading && m_listLoad.Count == 0)
        {
            return;
        }
        if (!bStartLoading)
        {
            data = m_listLoad[0];
            m_listLoad.RemoveAt(0);
        }

        if (data == null)
        {
            return;
        }
        if (data.www == null)
        {
            if (data.data != null)
            {
                //RevisionData revisionData = data.data as RevisionData;
                //m_CurFileSize = revisionData.revisionFile.size;
            }

            bStartLoading = true;
            string strWgetUrl = data.strServerUrl;
            //Debug.LogError(strWgetUrl);
            data.www = new WWW(strWgetUrl);
            //Debug.Log(strWgetUrl);
            data.www.threadPriority = ThreadPriority.High;
            m_fCurProcess           = 0;
        }
        if (data.www.error != null)
        {
            Debug.Log(data.www.error + data.strServerUrl);
            //RestartCurUrl();
            data          = null;
            bStartLoading = false;
        }
        else if (data.www.isDone && data.www.progress == 1)
        {
            m_fCurProcess = 0;

            OnDoneComplete(data);

            data          = null;
            bStartLoading = false;
        }
        else
        {
            //Camera.main.GetComponent<AssetManager>().textshow.text += "    m_fCurProcess::  " + m_fCurProcess;
            //Debug.Log("m_fCurProcess    " + m_fCurProcess);
            m_fCurProcess = data.www.progress;
        }
    }
Exemplo n.º 6
0
 private void OnDoneComplete(DownLoadALLData data)
 {
     LoadFile(data.item, data.www.bytes);
     Debug.LogError("开始下载了。。。。。" + data.item);
 }
Exemplo n.º 7
0
    public void UpdateDownload()
    {
        //Debug.LogError("开始下载把");
        //return;
        if (m_listTempLoad != null && m_listTempLoad.Count > 0)
        {
            int nCount = m_listTempLoad.Count;
            for (int i = 0; i < nCount; i++)
            {
                //Debug.Log("Temp   "+m_listTempLoad[i].strWgetUrl);
                DownLoadALLData dataTemp = m_listTempLoad[i];
                m_listLoad.Add(dataTemp);
            }
            m_listTempLoad.Clear();
        }
        //Debug.LogError("还剩下多少?" + m_listLoad.Count);
        if (!bStartLoading && m_listLoad.Count == 0)
        {
            DoneLoadOver = true;
            return;
        }
        if (!bStartLoading)
        {
            data = m_listLoad[0];
            m_listLoad.RemoveAt(0);
        }

        if (data == null)
        {
            return;
        }
        if (data.www == null)
        {
            DoneLoadOver = false;
            if (data.data != null)
            {
                //RevisionData revisionData = data.data as RevisionData;
                //m_CurFileSize = revisionData.revisionFile.size;
            }
            bStartLoading = true;
            string strWgetUrl = data.strServerUrl;
            Debug.LogError(strWgetUrl);
            data.www = new WWW(strWgetUrl);
            //Debug.Log(strWgetUrl);
            data.www.threadPriority = ThreadPriority.High;
            m_fCurProcess           = 0;
        }
        if (data.www.error != null)
        {
            Debug.Log(data.www.error + data.strServerUrl);
            //RestartCurUrl();
            data          = null;
            bStartLoading = false;
        }
        else if (data.www.isDone && data.www.progress == 1)
        {
            m_fCurProcess = 0;

            OnDoneComplete(data);

            data          = null;
            bStartLoading = false;
            time          = 10f;
        }
        else
        {
            m_fCurProcess = data.www.progress;
            time         -= Time.deltaTime;
            if (time <= 0)
            {
                if (m_fCurProcess >= 0.5f)
                {
                    Debug.Log("继续下载");
                }
                else
                {
                    Debug.LogWarning("资源错误");
                    time          = 10;
                    data          = null;
                    bStartLoading = false;
                }
            }
        }
    }
Exemplo n.º 8
0
 private void OnDoneComplete(DownLoadALLData data)
 {
     LoadFile(data.item, data.www.bytes);
     Debug.LogWarning("下载了成功了。。。。。" + data.item);
 }