Exemple #1
0
        private static void HttpDown_FileExit(string httpUrl, Action <string> callback, GameObject sender, string localPath)
        {
            string _fileRelativeNamePath = httpUrl.GetFilePathWithOneDirectory(); //getfile path with one dicrionary path and fileName .

            #region   文件存在
            //Debug.Log("File Exit ::" + localPath);
            HttpProtocolHelper httpHead = new HttpProtocolHelper();
            httpHead.m_Url    = httpUrl;
            httpHead.m_Method = "HEAD";
            httpHead.m_HttpFinishDownHandle = (bool isHttpDownLoadOk, string _FileName, HttpWebResponse response) =>
            {
                Loom.QueueOnMainThread(() =>
                {   //Go to Main Thread
                    CheckWhetherNeedToDown(localPath, response, _fileRelativeNamePath, httpUrl, callback);
                }); //main thread
            };      //handle
            currentTaskCount++;
            ////下载头信息
            httpHead.GetHttpResponse();
            #endregion
        }
Exemple #2
0
        public static void HttpDownLoadHeadOnly(string httpUrl, Action <string> callback, GameObject sender)
        {
            //   Debug.Log("AA " + currentTaskCount);
            if (currentTaskCount >= MaxTaskCount)
            {
                EventCenter.Instance.DelayDoEnumerator(0.1f, () =>
                {
                    HttpDownLoadHeadOnly(httpUrl, callback, sender);
                });
                return;
            }

            HttpProtocolHelper httpHead = new HttpProtocolHelper();

            httpHead.m_Url    = httpUrl;
            httpHead.m_Method = "HEAD";
            httpHead.m_HttpFinishDownHandle = (bool isHttpDownLoadOk, string _FileName, HttpWebResponse response) =>
            {
                Loom.QueueOnMainThread(() =>
                {     //Go to Main Thread
                    if (isHttpDownLoadOk)
                    { //Complete DowLoad
                        if (callback != null)
                        {
                            callback(response.ContentLength.ToString());                    //DownLoad Faile
                        }
                    }
                    else
                    {
                        if (callback != null)
                        {
                            callback(null);                    //DownLoad Faile
                        }
                    }
                });
            };
            currentTaskCount++;
            ////下载头信息
            httpHead.GetHttpResponse();
        }