コード例 #1
0
        /// <summary>
        ///     Create a scene and its initial base structures.
        /// </summary>
        /// <param name="regionInfo"></param>
        /// <param name="configSource"></param>
        /// <returns></returns>
        public IScene CreateScene(ISimulationDataStore dataStore, RegionInfo regionInfo)
        {
            AgentCircuitManager circuitManager = new AgentCircuitManager();
            List<IClientNetworkServer> clientServers = UniverseModuleLoader.PickupModules<IClientNetworkServer>();
            List<IClientNetworkServer> allClientServers = new List<IClientNetworkServer>();
            foreach (IClientNetworkServer clientServer in clientServers)
            {
                clientServer.Initialize((uint)regionInfo.RegionPort, m_configSource, circuitManager);
                allClientServers.Add(clientServer);
            }

            AsyncScene scene = new AsyncScene();
            scene.AddModuleInterfaces(m_simBase.ApplicationRegistry.GetInterfaces());
            scene.Initialize(regionInfo, dataStore, circuitManager, allClientServers);

            return scene;
        }
コード例 #2
0
        public void Initialize(RegionInfo regionInfo, ISimulationDataStore dataStore,
            AgentCircuitManager authen, List<IClientNetworkServer> clientServers)
        {
            Initialize(regionInfo);

            //Set up the clientServer
            m_clientServers = clientServers;
            foreach (IClientNetworkServer clientServer in clientServers)
                clientServer.AddScene(this);

            m_sceneManager = RequestModuleInterface<ISceneManager>();
            m_simDataStore = dataStore;

            m_config = m_sceneManager.ConfigSource;
            m_authenticateHandler = authen;

            m_UniverseEventManager = new UniverseEventManager();
            m_eventManager = new EventManager();
            m_permissions = new ScenePermissions(this);

            m_sceneGraph = new SceneGraph(this, m_regInfo);

            #region Region Config

            IConfig packetConfig = m_config.Configs["PacketPool"];
            if (packetConfig != null)
            {
                PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
                PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
            }

            #endregion Region Config

            m_basesimfps = 45f;
            m_basesimphysfps = 45f;

            m_basesimphysfps = Config.Configs["Physics"].GetFloat("BasePhysicsFPS", 45f);
            m_basesimfps = Config.Configs["Protection"].GetFloat("BaseRateFramesPerSecond", 45f);
            if (m_basesimphysfps > 45f)
                m_basesimphysfps = 45f;
            if (m_basesimfps > 45f)
                m_basesimfps = 45f;

            if (m_basesimphysfps > m_basesimfps)
                m_basesimphysfps = m_basesimfps;

            m_updatetimespan = 1000/m_basesimfps;
            m_physicstimespan = 1000/m_basesimphysfps;

            #region Startup Complete config

            EventManager.OnAddToStartupQueue += AddToStartupQueue;
            EventManager.OnModuleFinishedStartup += FinishedStartup;
            //EventManager.OnStartupComplete += StartupComplete;

            AddToStartupQueue("Startup");

            #endregion
        }
コード例 #3
0
        public void Initialize(uint port, IConfigSource configSource, AgentCircuitManager circuitManager)
        {
            IConfig networkConfig = configSource.Configs["Network"];
            IPAddress internalIP = IPAddress.Any;
            if (networkConfig != null)
                IPAddress.TryParse(networkConfig.GetString("internal_ip", "0.0.0.0"), out internalIP);

            InitThreadPool(15);

            base.Initialize(internalIP, (int)port);

            #region Environment.TickCount Measurement

            // Measure the resolution of Environment.TickCount
            TickCountResolution = 0f;
            for (int i = 0; i < 5; i++)
            {
                int start = Environment.TickCount;
                int now = start;
                while (now == start)
                    now = Environment.TickCount;
                TickCountResolution += (now - start)*0.2f;
            }
            //MainConsole.Instance.Info("[LLUDP Server]: Average Environment.TickCount resolution: " + TickCountResolution + "ms");
            TickCountResolution = (float) Math.Ceiling(TickCountResolution);

            #endregion Environment.TickCount Measurement

            m_circuitManager = circuitManager;
            int sceneThrottleBps = 0;

            IConfig config = configSource.Configs["ClientStack.LindenUDP"];
            if (config != null)
            {
                m_asyncPacketHandling = config.GetBoolean("async_packet_handling", false);
                m_recvBufferSize = config.GetInt("client_socket_rcvbuf_size", 0);
                sceneThrottleBps = config.GetInt("scene_throttle_max_bps", 0);

                PrimUpdatesPerCallback = config.GetInt("PrimUpdatesPerCallback", 60);
                AvatarUpdatesPerCallBack = config.GetInt("AvatarUpdatesPerCallback", 80);
                TextureSendLimit = config.GetInt("TextureSendLimit", 25);

                m_defaultRTO = config.GetInt("DefaultRTO", 1000);
                m_maxRTO = config.GetInt("MaxRTO", 20000);
                ClientTimeOut = config.GetInt("ClientTimeOut", 120);
            }
            else
            {
                PrimUpdatesPerCallback = 60;
                AvatarUpdatesPerCallBack = 80;
                TextureSendLimit = 25;
                ClientTimeOut = 120;
            }

            #region BinaryStats

            config = configSource.Configs["Statistics.Binary"];
            m_shouldCollectStats = false;
            if (config != null)
            {
                if (config.Contains("enabled") && config.GetBoolean("enabled"))
                {
                    if (config.Contains("collect_packet_headers"))
                        m_shouldCollectStats = config.GetBoolean("collect_packet_headers");
                    if (config.Contains("packet_headers_period_seconds"))
                    {
                        binStatsMaxFilesize = TimeSpan.FromSeconds(config.GetInt("region_stats_period_seconds"));
                    }
                    if (config.Contains("stats_dir"))
                    {
                        lock (binStatsLogLock) {
                            binStatsDir = config.GetString ("stats_dir");
                        }
                    }
                }
                else
                {
                    m_shouldCollectStats = false;
                }
            }

            #endregion BinaryStats

            if (sceneThrottleBps != 0)
                m_throttle = new TokenBucket(null, sceneThrottleBps, 0);
            m_throttleRates = new ThrottleRates(configSource);
        }