Esempio n. 1
0
    public override void handleErrorOcurr()
    {
        ControllerEx ctrlEx = Core.EntityMgr.getControllerByID(SenderID);

        if (ctrlEx != null)
        {
            if (!string.IsNullOrEmpty(errorInfo))
            {
                ctrlEx.Http_ErrorOccured(request, errorInfo);
            }
            else
            {
                if (response == null)
                {
                    response = new ExceptionResponse();
                }
                ExceptionResponse ex = response as ExceptionResponse;
                if (ex == null)
                {
                    ex = new ExceptionResponse();
                }
                ctrlEx.Http_ErrorOccured(request, ex.HttpError);
            }
        }
        else
        {
            ConsoleEx.DebugLog("Controller doesn't exist.", ConsoleEx.YELLOW);
        }
    }
        protected void Application_Error(object sender, EventArgs e)
        {
            HttpContext ctx = HttpContext.Current;
            Exception   ex  = ctx.Server.GetLastError();

            ctx.Response.Clear();

            RequestContext rc         = ((MvcHandler)ctx.CurrentHandler).RequestContext;
            IController    controller = new ControllerEx();          // Тут можно использовать любой контроллер, например тот что используется в качестве базового типа
            var            context    = new ControllerContext(rc, (ControllerBase)controller);

            var viewResult = new ViewResult();

            var httpException = ex as HttpException;

            if (httpException != null)
            {
                switch (httpException.GetHttpCode())
                {
                case 404:
                    viewResult.ViewName = "Error";
                    break;

                case 500:
                    viewResult.ViewName = "Error";
                    break;

                default:
                    viewResult.ViewName = "Error";
                    break;
                }
            }
            else
            {
                viewResult.ViewName = "Error";
            }

            Kesco.Logging.Logger.WriteEx(ex);

            viewResult.ViewData.Model = new HandleErrorInfo(ex, context.RouteData.GetRequiredString("controller"), context.RouteData.GetRequiredString("action"));
            viewResult.ExecuteResult(context);
            ctx.Server.ClearError();
        }
Esempio n. 3
0
    public override void handleBackGroundCompleted()
    {
        ControllerEx ctrlEx = Core.EntityMgr.getControllerByID(SenderID);

        if (ctrlEx != null)
        {
            if (response.status != BaseResponse.ERROR)
            {
                ctrlEx.Http_OnReceive_OK(request, response);
            }
            else
            {
                ctrlEx.Http_OnReceive_Fail(request, response);
            }
        }
        else
        {
            ConsoleEx.DebugLog("Controller doesn't exist.", ConsoleEx.YELLOW);
        }
    }
Esempio n. 4
0
        ///
        /// 设备的状态发生改变的时候
        ///
        public void handleStateChg(DeviceState NowState)
        {
            ConsoleEx.DebugLog("Device Status Changed. " + mPreState.ToString() + " -> " + NowState.ToString(), ConsoleEx.RED);

            mPreState = mNowState;
            mNowState = NowState;

            StateParam <DeviceState> param = new StateParam <DeviceState>();

            param.NowGameState  = mNowState;
            param.prevGameState = mPreState;

            //优先处理核心处理层
            foreach (IDeviceState listener in Owner)
            {
                switch (NowState)
                {
                case DeviceState.GameLaunched:
                    listener.OnGameLaunched(param);
                    break;

                case DeviceState.GamePaused:
                    listener.OnPaused(param);
                    break;

                case DeviceState.GameResume:
                    listener.OnResume(param);
                    break;

                case DeviceState.GameQuit:
                    listener.OnQuit(param);
                    break;
                }
            }

            EntityManager entityMgr = Core.EntityMgr;

            //再处理控制层
            foreach (LogicalType controller in binder.IControllerDevice)
            {
                ControllerEx ctrl = entityMgr.getEntityByLogicalType(controller);
                if (ctrl != null && ctrl is IDeviceState)
                {
                    IDeviceState idev = ctrl as IDeviceState;
                    switch (NowState)
                    {
                    case DeviceState.GameLaunched:
                        idev.OnGameLaunched(param);
                        break;

                    case DeviceState.GamePaused:
                        idev.OnPaused(param);
                        break;

                    case DeviceState.GameResume:
                        idev.OnResume(param);
                        break;

                    case DeviceState.GameQuit:
                        idev.OnQuit(param);
                        break;
                    }
                }
            }
        }
Esempio n. 5
0
        ///
        /// 游戏逻辑的状态发生改变的时候
        ///
        public void handleStateChg(StateParam <GameState> param, GameState NowState)
        {
            ConsoleEx.DebugLog("GamePlay Status Changed. " + mPreState.ToString() + " -> " + NowState.ToString(), ConsoleEx.RED);

            mPreState           = mNowState;
            mNowState           = NowState;
            param.NowGameState  = mNowState;
            param.prevGameState = mPreState;

            //优先处理核心处理层
            foreach (IGameState listener in Owner)
            {
                switch (NowState)
                {
                case GameState.DayChanged:
                    break;

                case GameState.Logined:
                    listener.OnLogin(param);
                    break;

                case GameState.Logout:

                    break;

                case GameState.LevelChanged:
                    listener.OnLevelChanged(param);

                    LevelChanged lvl = param.obj as LevelChanged;
                    if (lvl != null)
                    {
                        lastScene = lvl.curLevel;
                    }
                    break;
                }
            }


            EntityManager entityMgr = Core.EntityMgr;

            //再处理控制层
            foreach (LogicalType controller in binder.IControllerGamePlay)
            {
                ControllerEx ctrl = entityMgr.getEntityByLogicalType(controller);
                if (ctrl != null && ctrl is IGameState)
                {
                    IGameState igame = ctrl as IGameState;
                    switch (NowState)
                    {
                    case GameState.DayChanged:
                        break;

                    case GameState.Logined:
                        igame.OnLogin(param);
                        break;

                    case GameState.Logout:
                        break;

                    case GameState.LevelChanged:
                        igame.OnLevelChanged(param);
                        break;
                    }
                }
            }
        }