Exemple #1
0
        /*
         * Running in the main thread
         */
        void Http_OnException(HttpTask task)
        {
            if (task != null)
            {
                if (!string.IsNullOrEmpty(task.errorInfo))
                {
                    ConsoleEx.DebugLog(" --> Event Center Recevied Http Exception." + task.errorInfo);
                }
                ///
                /// ----------- 分开try catch的原因是:有可能处理HttpResponse时报出异常 , 异常之后无法正确的处理回调,-----------
                ///

                //we should send following code to the main thread
                try {
                    AsyncTask.QueueOnMainThread(() => { task.handleErrorOcurr(); });
                } catch (Exception ex) {
                    ConsoleEx.DebugLog(ex.ToString(), ConsoleEx.RED);
                }

                //Default handler if ErrorOccured is null
                if (DefaultHttpExce != null && task.ErrorOccured == null)
                {
                    try {
                        AsyncTask.QueueOnMainThread(() => { DefaultHttpExce(task); });
                    } catch (Exception ex) {
                        ConsoleEx.DebugLog(ex.ToString(), ConsoleEx.RED);
                    }
                }
            }
        }
        public async Task <bool> CopyChunkToTransferAsync(TransferConnection transfer, string url, long filePos, long length)
        {
            var parsedUrl = new HttpUrl(url);

            var pool = GetPool(parsedUrl.Server);

            var task = new HttpTask
            {
                Url          = url,
                Transfer     = transfer,
                FilePosition = filePos,
                Length       = length
            };

            await pool.ExecuteTaskAsync(task).ConfigureAwait(false);

            if (task.Completed)
            {
                SegmentDelay.Update((int)task.ExecutionTime.TotalMilliseconds);
            }

            Interlocked.Add(ref _totalDownloaded, length);

            if (!task.Completed)
            {
                logger.Error("Unable to complete the task");
            }

            return(task.Completed);
        }
    void OnDayChanged(TimerTask tTask)
    {
        ///
        /// 新手引导的时候不能执行
        ///
        if (Core.Data.guideManger.isGuiding)
        {
            return;
        }

        HttpTask task = new HttpTask(ThreadType.MainThread, TaskResponse.Default_Response);

        task.AppendCommonParam(RequestType.MESSAGE_INFORMATION, new PlayerIDParam(Core.Data.playerManager.PlayerID, 100));
        task.afterCompleted = (BaseHttpRequest request, BaseResponse response) => {
            recordDayChanged(Core.Data.playerManager.RTData.systemTime);

            ///
            /// -------- 弹出提醒用户签到 --------
            ///
            if (CurScenesName == SceneName.MAINUI)
            {
                string content = Core.Data.stringManager.getString(55);
                string btn     = Core.Data.stringManager.getString(5030);
                UIInformation.GetInstance().SetInformation(content, btn, DBUIController.mDBUIInstance.SyncBackToMainUI, DBUIController.mDBUIInstance.SyncBackToMainUI);
            }
        };
        task.ErrorOccured = (BaseHttpRequest request, string error) => { ConsoleEx.DebugLog("SendFightRequest is error!"); };
        task.DispatchToRealHandler();
    }
    public void SendMsg()
    {
        ComLoading.Open();
        if (NoticeManager.openSign && NoticeManager.firstShowState == 1)
        {
            ComLoading.Close();
            SetSevenRewardDetail(NoticeManager._AlertInfo.sevenSgin);
            if (Core.Data.guideManger.isGuiding)
            {
                Core.Data.guideManger.AutoRUN();
            }
        }
        else
        {
            GetSevenRewardListParam param = new GetSevenRewardListParam(int.Parse(Core.Data.playerManager.PlayerID));
            HttpTask task = new HttpTask(ThreadType.MainThread, TaskResponse.Default_Response);

            task.AppendCommonParam(RequestType.SEVENDAYREWARD, param);

            task.ErrorOccured   += testHttpResp_Error;
            task.afterCompleted += testHttpResp_UI;

            task.DispatchToRealHandler();
        }
    }
Exemple #5
0
    void SendBattleRequest()
    {
        HttpTask task = new HttpTask(ThreadType.MainThread, TaskResponse.Default_Response);

        task.AppendCommonParam(RequestType.FIGHT_FULISA, new BattleParam(Core.Data.playerManager.PlayerID, -1, 0, 0));
        task.afterCompleted = BattleResponseFUC;
        task.DispatchToRealHandler();
    }