Ejemplo n.º 1
0
        public void Drive()
        {
            if (this.isDownloadingPaused)
            {
                return;
            }
            this.netFrame.Drive();
            while (this.resultQueue.get_Count() > 0)
            {
                Message message = this.resultQueue.Dequeue() as Message;
                if (message.action != null)
                {
                    message.action.Invoke(message.status, message.content);
                }
            }
            int num = Utils.NowSeconds();

            if (this.atmUniqueSocketId < 0L && !this.isAtmConnecting && this.lastConnectAtmTime + 5 < num)
            {
                this.CheckAtmSession();
            }
            if (this.brokerUniqueSocketId < 0L && !this.isBrokerConnecting && this.lastConnectBrokerTime + 5 < num)
            {
                this.CheckBrokerSession();
            }
            this.TrySendAtmReport();
            this.TrySendBrokerRequest();
            while (this.logicDriveQueue.get_Count() > 0)
            {
                Message message2 = this.logicDriveQueue.Dequeue() as Message;
                if (message2.action != null)
                {
                    message2.action.Invoke(message2.status, message2.content);
                }
            }
            while (this.downloadRequestQueue.get_Count() > 0)
            {
                NetLogic.DownloadRequest request = this.downloadRequestQueue.Dequeue() as NetLogic.DownloadRequest;
                Action <int, Dictionary <string, object> > action = delegate(int downloadRet, Dictionary <string, object> content)
                {
                    if (downloadRet == 100)
                    {
                        Logger.DEBUG(string.Empty);
                        string url = content.get_Item("locationUrl") as string;
                        this.AddDownload(url, request.size, request.md5, request.destFile, request.curRedirectionTimes + 1, request.action);
                    }
                    else
                    {
                        Logger.DEBUG(string.Empty);
                        Message message3 = new Message();
                        message3.status  = downloadRet;
                        message3.action  = request.action;
                        message3.content = content;
                        this.EnqueueResult(message3);
                    }
                };
                this.DownloadFile(request.url, request.size, request.md5, request.destFile, request.curRedirectionTimes, action);
            }
        }
Ejemplo n.º 2
0
 public void AddDownload(string url, int size, string md5, string destFile, int curRedirectionTimes, Action <int, Dictionary <string, object> > action)
 {
     Logger.DEBUG(url);
     NetLogic.DownloadRequest downloadRequest = new NetLogic.DownloadRequest();
     downloadRequest.url                 = url;
     downloadRequest.size                = size;
     downloadRequest.md5                 = md5;
     downloadRequest.destFile            = destFile;
     downloadRequest.curRedirectionTimes = curRedirectionTimes;
     downloadRequest.action              = action;
     this.downloadRequestQueue.Enqueue(downloadRequest);
 }