public DownWebRequestItem GetFreeReqItem()
 {
     for (int i = 0; i < agentList.Count; i++)
     {
         if (!agentList[i].IsRun)
         {
             return(agentList[i]);
         }
     }
     if (agentList.Count < MAX_REQUEST)
     {
         DownWebRequestItem webRequest = new DownWebRequestItem(this.mono, WebRequestSuccessHandle);
         webRequest.index = agentList.Count;
         agentList.Add(webRequest);
         return(webRequest);
     }
     return(null);
 }
        public bool Request(DownLoadFileUnit downLoadFileUnit)
        {
            if (string.IsNullOrEmpty(downLoadFileUnit.DownLoadUrl))
            {
                return(false);
            }

            if (string.IsNullOrEmpty(downLoadFileUnit.FilePath))
            {
                return(false);
            }

            if (!CheckFreeWebRequest())
            {
                return(false);
            }

            DownWebRequestItem webRequest = GetFreeReqItem();

            webRequest.Send(downLoadFileUnit);
            return(true);
        }
 public void WebRequestSuccessHandle(DownLoadFileUnit downLoadFileUnit, bool isErro, DownWebRequestItem item)
 {
     if (!isErro)
     {
         item.Destroy();
         curReconnectionCount = 0;
         this.successSize    += downLoadFileUnit.Length;
         if (OneFileDownloadSuccess != null)
         {
             OneFileDownloadSuccess(downLoadFileUnit);
         }
         if (!IsSuccess())
         {
             Check();
             return;
         }
         if (WebRequestSuccess != null)
         {
             WebRequestSuccess(downLoadFileUnit);
         }
     }
     else
     {
         item.Reconnection();
     }
 }