コード例 #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);
        }