Exemple #1
0
        public static LogicServerConnector GetFreeLogicServer(GatewayClient client)
        {
            LogicServerConnector connector = LogicServerMgr[m_freeID];

            if (connector != null && connector.Fulled == false)
            {
                return(connector);
            }

            LogicServerConnector connect = LogicServerMgr.SelectSingle(conn => conn.Fulled == false);

            if (connect != null)
            {
                m_freeID = connect.ID;

                connector = connect;

                return(connect);
            }
            else if (connector == null)
            {
                //TODO: 通知客户端逻辑服务器已满 稍候登陆

                ClientMsgPacket pkg = new ClientMsgPacket();

                pkg.MsgFlag = MsgFlag.NoneLogic;

                client.SendTcp(pkg);

                log.Warn("所有逻辑服务器满载 请增开新的逻辑服务器");
            }

            return(connector);
        }
Exemple #2
0
        public static void CheckMaxClientCount(GatewayClient client)
        {
            lock (m_syncRoot)
            {
                if (Fulled)
                {
                    //TODO: 服务器已满 请求中心服务器更换网关

                    ChangeGatewayPacket pkg = new ChangeGatewayPacket();

                    pkg.ClientID = client.ClientID;

                    GatewayGlobal.Send2Center(pkg, client);

                    return;
                }
            }

            if (ClientMgr.Instance.ClientCount >= GatewayServerConfig.Configuration.MaxClients)
            {
                lock (m_syncRoot)
                {
                    Fulled = true;

                    //TODO: 通知中心服务器此网关已满 并N分钟后重置为未满

                    UpdateServerFullPacket pkg = new UpdateServerFullPacket();

                    pkg.ClientID = client.ClientID;

                    GatewayGlobal.Send2Center(pkg, client);

                    m_timer.Interval  = 300 * 1000;
                    m_timer.Elapsed  += new ElapsedEventHandler(m_timer_Elapsed);
                    m_timer.AutoReset = true;
                    m_timer.Start();
                }
            }
            else
            {
                //TODO: 通知客户端登陆

                NoticeLoginPacket pkg = new NoticeLoginPacket();

                client.SendTcp(pkg);
            }
        }
Exemple #3
0
        public static LogicServerConnector GetFreeLogicServer(GatewayClient client)
        {
            LogicServerConnector connector = LogicServerMgr[m_freeID];

            if (connector != null && connector.Fulled == false)
            {
                return connector;
            }

            LogicServerConnector connect = LogicServerMgr.SelectSingle(conn => conn.Fulled == false);

            if (connect != null)
            {
                m_freeID = connect.ID;

                connector = connect;

                return connect;
            }
            else if(connector == null)
            {
                //TODO: 通知客户端逻辑服务器已满 稍候登陆

                ClientMsgPacket pkg = new ClientMsgPacket();

                pkg.MsgFlag = MsgFlag.NoneLogic;

                client.SendTcp(pkg);

                log.Warn("所有逻辑服务器满载 请增开新的逻辑服务器");
            }

            return connector;
        }
Exemple #4
0
        public static void CheckMaxClientCount(GatewayClient client)
        {
            lock (m_syncRoot)
            {
                if (Fulled)
                {
                    //TODO: 服务器已满 请求中心服务器更换网关

                    ChangeGatewayPacket pkg = new ChangeGatewayPacket();

                    pkg.ClientID = client.ClientID;

                    GatewayGlobal.Send2Center(pkg, client);

                    return;
                }
            }

            if (ClientMgr.Instance.ClientCount >= GatewayServerConfig.Configuration.MaxClients)
            {
                lock (m_syncRoot)
                {
                    Fulled = true;

                    //TODO: 通知中心服务器此网关已满 并N分钟后重置为未满

                    UpdateServerFullPacket pkg = new UpdateServerFullPacket();

                    pkg.ClientID = client.ClientID;

                    GatewayGlobal.Send2Center(pkg, client);

                    m_timer.Interval = 300 * 1000;
                    m_timer.Elapsed += new ElapsedEventHandler(m_timer_Elapsed);
                    m_timer.AutoReset = true;
                    m_timer.Start();
                }
            }
            else
            {
                //TODO: 通知客户端登陆

                NoticeLoginPacket pkg = new NoticeLoginPacket();

                client.SendTcp(pkg);
            }
        }