Пример #1
0
        public static HttpByteInfo Allocate(string m_srcUrl, WebRequestByteEvent webRequestTextEvent, string m_savePath = "",
                                            WebRequestProcessEvent processEvent = null)
        {
            HttpByteInfo httpByteInfo = new HttpByteInfo();

            httpByteInfo.m_srcUrl            = m_srcUrl;
            httpByteInfo.webRequestByteEvent = webRequestTextEvent;
            httpByteInfo.m_savePath          = m_savePath;
            httpByteInfo.processEvent        = processEvent;
            return(httpByteInfo);
        }
Пример #2
0
 public void StartByteRequest(string url, string SavePath, WebRequestByteEvent webRequestGetEvent)
 {
     if (JudgeNetworkState())
     {
         HttpByteTool httpTool = new HttpByteTool();
         httpTool.StartWebRequest(url, SavePath, webRequestGetEvent);
     }
     else
     {
         webRequestGetEvent(default(byte[]), DownStatus.NoNetwork, "");
     }
 }
Пример #3
0
 public void StartByteDown(string m_srcUrl, WebRequestByteEvent webRequestTextEvent, string m_savePath = "",
                           WebRequestProcessEvent processEvent = null)
 {
     if (JudgeNetworkState())
     {
         if (!URLToHttpBase.ContainsKey(m_srcUrl))
         {
             HttpByte httpTxt = new HttpByte(HttpByteInfo.Allocate(m_srcUrl, webRequestTextEvent, m_savePath, processEvent));
             AddRequest(m_srcUrl, httpTxt);
         }
     }
     else
     {
         webRequestTextEvent(default(byte[]), DownStatus.NoNetwork, "");
     }
 }
Пример #4
0
        public IEnumerator RealWebRequest(string url, string SavePath,
                                          WebRequestByteEvent webRequestGetEvent)
        {
            webRequest        = UnityWebRequest.Get(url);
            httpRequestCount += 1;
            yield return(webRequest.SendWebRequest());

            if (webRequest.error == null || webRequest.error == "")
            {
                if (SavePath != null && SavePath != "")
                {
                    FileHelper.CreatFile(SavePath, webRequest.downloadHandler.data, true);
                }
                if (webRequestGetEvent != null)
                {
                    webRequestGetEvent.Invoke(webRequest.downloadHandler.data, DownStatus.Sucess, "");
                }
                webRequest = null;
            }
            else
            {
                webRequest = null;
                DownManager.Instance.DebugDownError(httpRequestCount, url, webRequest.error);
                if (httpRequestCount <= 3)
                {
                    DownManager.Instance.RegisterRequest(RealWebRequest(url, SavePath, webRequestGetEvent));
                }
                else
                {
                    if (webRequestGetEvent != null)
                    {
                        webRequestGetEvent.Invoke(default(byte[]), DownStatus.Fail, webRequest.error);
                    }
                }
            }
        }
Пример #5
0
 public void StartWebRequest(string url, string SavePath, WebRequestByteEvent webRequestGetEvent)
 {
     httpRequestCount = 0;
     DownManager.Instance.RegisterRequest(RealWebRequest(url, SavePath, webRequestGetEvent));
 }