Esempio n. 1
0
        protected void Application_Start(object sender, EventArgs e)
        {
            #region 清理登录标记
            engineBll.ClearLoginState();
            #endregion

            #region modified by dean 找出过期的USER并停用AGENT&PLAYER

            StopChipIn(10*60*1000);//这里设定TIMER周期,根据现在的业务逻辑暂时设置为每10分钟执行一次

            #endregion

            //CommonFunction.DirPath = Server.MapPath(@"~\Resource\");
            CommonFunction.DirPath = ConfigurationManager.AppSettings["ResourceFile"];

            //Todo Unit Test
            //betEngine = new BetEngineStub();
            //Todo Integration Test
            betEngine = new BetEngine();

            // 启动时查询
            // 1.登录所有玩家  LoginPlayers(List<Player> 玩家列表);
            // 2.登录所有Agent LoginAgents(List<Agent> agent列表);
            // 3.Agent监测的ghost列表  RefreshGhosts(Agent agent对象,List<Ghost> ghosts agent监测的列表);
            // 4.设置player跟随的ghost(一对一) SetFollowRelationship(Player 玩家对象,Ghost 玩家跟注的ghost,Agent ghost所属的agent);

            List<Player> listPlayer = engineBll.getEnginePlayerFollowGhost();
            List<Agent> listAgent = engineBll.getEngineAgent();

            if (listPlayer.Count > 0)
            {
                betEngine.LoginPlayers(listPlayer);
            }

            if (listAgent.Count > 0)
            {
                betEngine.LoginAgents(listAgent);
            }

            if (listAgent.Count > 0)
            {
                for (int i = 0; i < listAgent.Count; i++)
                {
                    if (listAgent[i].Id > 0 && engineBll.getEngineGhostByAgentID(listAgent[i].Id).Count > 0)
                        betEngine.RefreshGhosts(listAgent[i], engineBll.getEngineGhostByAgentID(listAgent[i].Id));
                }
            }

            if (listPlayer.Count > 0)
            {
                Ghost g = null;
                Agent a = null;
                for (int i = 0; i < listPlayer.Count; i++)
                {
                    if (listPlayer[i].Attachment2Ghost != null && listPlayer[i].Attachment2Ghost.ghostId > 0)
                    {
                        g = engineBll.getEngineGhostByPlayerID(listPlayer[i].Attachment2Ghost.ghostId);
                        if (g != null && g.ghostId > 0)
                        {
                            a = engineBll.getEngineAgentByID(g.Belong2Agent.Id);
                            if (g.Belong2Agent != null && g.Belong2Agent.Id > 0 && a != null && a.Id > 0)
                                betEngine.SetFollowRelationship(listPlayer[i], g, a);
                        }
                    }
                }
            }

            // 添加Agent
            // 2.登录所有Agent LoginAgents(List<Agent> agent列表);
            // 3.Agent监测的ghost列表  RefreshGhosts(Agent agent对象,List<Ghost> ghosts agent监测的列表);

            // 添加玩家
            // 1.登录所有玩家  LoginPlayers(List<Player> 玩家列表);
            // 4.设置player跟随的ghost(一对一) SetFollowRelationship(Player 玩家对象,Ghost 玩家跟注的ghost,Agent ghost所属的agent);

            // 关闭agent
            //LogoutAgent(Agent agent)

            // 关闭player
            //LogoutPlayer(Player player)

            // player改变跟注ghost
            // 4.设置player跟随的ghost(一对一) SetFollowRelationship(Player 玩家对象,Ghost 玩家跟注的ghost,Agent ghost所属的agent);
        }