From 497ab5d7abec3c644a6340c1c64a2557dbade0ef Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 16 Jul 2007 23:25:35 +0000 Subject: [PATCH] * RegionApplicationBase restructuring now complete * Still has some weird bug in SimpleApp though. --- ...eSessionBase.cs => AgentCircuitManager.cs} | 4 +- OpenSim/Region/Application/OpenSimMain.cs | 80 +++++-------------- OpenSim/Region/ClientStack/ClientView.cs | 4 +- OpenSim/Region/ClientStack/PacketServer.cs | 4 +- .../ClientStack/RegionApplicationBase.cs | 52 ++++++++++-- OpenSim/Region/ClientStack/UDPServer.cs | 5 +- OpenSim/Region/Environment/RegionManager.cs | 2 +- OpenSim/Region/Environment/Scenes/Scene.cs | 4 +- OpenSim/Region/Examples/SimpleApp/MyWorld.cs | 2 +- OpenSim/Region/Examples/SimpleApp/Program.cs | 69 ++++++---------- prebuild.xml | 1 + 11 files changed, 100 insertions(+), 127 deletions(-) rename OpenSim/Framework/General/{AuthenticateSessionBase.cs => AgentCircuitManager.cs} (98%) diff --git a/OpenSim/Framework/General/AuthenticateSessionBase.cs b/OpenSim/Framework/General/AgentCircuitManager.cs similarity index 98% rename from OpenSim/Framework/General/AuthenticateSessionBase.cs rename to OpenSim/Framework/General/AgentCircuitManager.cs index 2d022869fe..c19d6b1a23 100644 --- a/OpenSim/Framework/General/AuthenticateSessionBase.cs +++ b/OpenSim/Framework/General/AgentCircuitManager.cs @@ -32,11 +32,11 @@ using OpenSim.Framework.Types; namespace OpenSim.Framework { - public class AuthenticateSessionsBase + public class AgentCircuitManager { public Dictionary AgentCircuits = new Dictionary(); - public AuthenticateSessionsBase() + public AgentCircuitManager() { } diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 074b34b873..61541cc690 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -46,6 +46,7 @@ using OpenSim.Region.Communications.OGS1; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment; using System.Text; +using System.Collections.Generic; namespace OpenSim { @@ -60,7 +61,9 @@ namespace OpenSim protected bool m_useConfigFile; public string m_configFileName; - protected CommunicationsManager commsManager; + protected List m_udpServers = new List(); + protected List m_regionData = new List(); + protected List m_localWorld = new List(); private bool m_silent; private string m_logFilename = "region-console-" + Guid.NewGuid().ToString() + ".log"; @@ -89,17 +92,13 @@ namespace OpenSim m_httpServer.AddStreamHandler(new SimStatusHandler()); } - AssetCache assetCache = m_assetCache; - assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey); - m_inventoryCache = new InventoryCache(); - if (m_sandbox) { - this.commsManager = new CommunicationsLocal( m_networkServersInfo, m_httpServer); + m_commsManager = new CommunicationsLocal( m_networkServersInfo, m_httpServer); } else { - this.commsManager = new CommunicationsOGS1( m_networkServersInfo, m_httpServer ); + m_commsManager = new CommunicationsOGS1( m_networkServersInfo, m_httpServer ); } string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions"); @@ -129,60 +128,15 @@ namespace OpenSim regionInfo.InitConfig(this.m_sandbox, regionConfig); regionConfig.Close(); + + UDPServer udpServer; + Scene scene = SetupScene(regionInfo, out udpServer); + + m_localWorld.Add(scene); - AuthenticateSessionsBase authenBase; - - if (m_sandbox) - { - AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); // new AuthenticateSessionsLocal(); - this.AuthenticateSessionsHandler.Add(authen); - authenBase = authen; - } - else - { - AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); //new AuthenticateSessionsRemote(); - this.AuthenticateSessionsHandler.Add(authen); - authenBase = authen; - } - - UDPServer udpServer = new UDPServer(regionInfo.InternalEndPoint.Port, assetCache, this.m_inventoryCache, this.m_log, authenBase); - m_udpServers.Add(udpServer); m_regionData.Add(regionInfo); - - StorageManager tmpStoreManager = GetStoreManager(regionInfo); - - Scene scene = new Scene(regionInfo, authenBase, commsManager, assetCache, tmpStoreManager, m_httpServer); - m_localWorld.Add(scene); - - udpServer.LocalWorld = scene; - - scene.LoadStorageDLL("OpenSim.Region.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded. - scene.LoadWorldMap(); - - PhysicsScene physicsScene = GetPhysicsScene(m_physicsEngine); - - scene.PhysScene = physicsScene; - scene.PhysScene.SetTerrain(scene.Terrain.getHeights1D()); - scene.LoadPrimsFromStorage(); - - //Master Avatar Setup - UserProfileData masterAvatar = commsManager.UserServer.SetupMasterUser(scene.RegionInfo.MasterAvatarFirstName, scene.RegionInfo.MasterAvatarLastName, scene.RegionInfo.MasterAvatarSandboxPassword); - if (masterAvatar != null) - { - m_log.Notice("Parcels - Found master avatar [" + masterAvatar.UUID.ToStringHyphenated() + "]"); - scene.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID; - scene.localStorage.LoadLandObjects((ILocalStorageLandObjectReceiver)scene.LandManager); - } - else - { - m_log.Notice("Parcels - No master avatar found, using null."); - scene.RegionInfo.MasterAvatarAssignedUUID = libsecondlife.LLUUID.Zero; - scene.localStorage.LoadLandObjects((ILocalStorageLandObjectReceiver)scene.LandManager); - } - scene.performParcelPrimCountUpdate(); - scene.StartTimer(); } // Start UDP servers @@ -193,15 +147,18 @@ namespace OpenSim } - protected override StorageManager GetStoreManager(RegionInfo regionInfo) + protected override StorageManager CreateStorageManager(RegionInfo regionInfo) { return new StorageManager("OpenSim.DataStore.NullStorage.dll", regionInfo.DataStore, regionInfo.RegionName); } + protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager) + { + return new Scene(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer); + } + protected override void Initialize() { - m_log.Verbose("Loading Configuration [{0}]", m_configFileName); - IGenericConfig localConfig = new XmlConfig(m_configFileName); localConfig.LoadData(); @@ -210,11 +167,14 @@ namespace OpenSim SetupFromConfigFile(localConfig); } + StartLog(); + m_networkServersInfo.InitConfig(m_sandbox, localConfig); m_httpServerPort = m_networkServersInfo.HttpListenerPort; localConfig.Close(); + m_assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey); } protected override LogBase CreateLog() diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 9fddc7b0a2..44466c6e38 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -76,7 +76,7 @@ namespace OpenSim.Region.ClientStack private AssetCache m_assetCache; private InventoryCache m_inventoryCache; private int cachedtextureserial = 0; - protected AuthenticateSessionsBase m_authenticateSessionsHandler; + protected AgentCircuitManager m_authenticateSessionsHandler; private Encoding enc = Encoding.ASCII; // Dead client detection vars private Timer clientPingTimer; @@ -84,7 +84,7 @@ namespace OpenSim.Region.ClientStack private int probesWithNoIngressPackets = 0; private int lastPacketsReceived = 0; - public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions ) + public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AgentCircuitManager authenSessions ) { m_world = world; m_clientThreads = clientThreads; diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs index 466fdde9de..41aaf3a312 100644 --- a/OpenSim/Region/ClientStack/PacketServer.cs +++ b/OpenSim/Region/ClientStack/PacketServer.cs @@ -133,7 +133,7 @@ namespace OpenSim.Region.ClientStack /// /// /// - protected virtual ClientView CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions) + protected virtual ClientView CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AgentCircuitManager authenSessions) { return new ClientView(remoteEP, initialcirpack, clientThreads, world, assetCache, packServer, inventoryCache, authenSessions ); } @@ -147,7 +147,7 @@ namespace OpenSim.Region.ClientStack /// /// /// - public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, InventoryCache inventoryCache, AuthenticateSessionsBase authenticateSessionsClass) + public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, InventoryCache inventoryCache, AgentCircuitManager authenticateSessionsClass) { ClientView newuser = CreateNewClient(epSender, useCircuit, ClientThreads, _localWorld, assetCache, this, inventoryCache, diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index 8467082194..1bb383f10c 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs @@ -31,6 +31,7 @@ using System.Net; using OpenSim.Assets; using OpenSim.Framework; using OpenSim.Framework.Console; +using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; using OpenSim.Framework.Types; @@ -39,6 +40,7 @@ using OpenSim.Region.Caches; using OpenSim.Region.Environment; using libsecondlife; using OpenSim.Region.Environment.Scenes; +using OpenSim.Framework.Communications; namespace OpenSim.Region.ClientStack { @@ -50,14 +52,11 @@ namespace OpenSim.Region.ClientStack protected DateTime m_startuptime; protected NetworkServersInfo m_networkServersInfo; - protected List m_udpServers = new List(); - protected List m_regionData = new List(); - protected List m_localWorld = new List(); protected BaseHttpServer m_httpServer; protected int m_httpServerPort; - protected List AuthenticateSessionsHandler = new List(); protected LogBase m_log; + protected CommunicationsManager m_commsManager; public RegionApplicationBase( ) { @@ -72,19 +71,19 @@ namespace OpenSim.Region.ClientStack Initialize(); - StartLog(); - ScenePresence.LoadTextureFile("avatar-texture.dat"); m_httpServer = new BaseHttpServer( m_httpServerPort ); m_log.Verbose("Starting HTTP server"); m_httpServer.Start(); + + m_inventoryCache = new InventoryCache(); } protected abstract void Initialize(); - private void StartLog() + protected void StartLog() { m_log = CreateLog(); MainLog.Instance = m_log; @@ -92,7 +91,7 @@ namespace OpenSim.Region.ClientStack protected abstract LogBase CreateLog(); protected abstract PhysicsScene GetPhysicsScene( ); - protected abstract StorageManager GetStoreManager(RegionInfo regionInfo); + protected abstract StorageManager CreateStorageManager(RegionInfo regionInfo); protected PhysicsScene GetPhysicsScene(string engine) { @@ -102,5 +101,42 @@ namespace OpenSim.Region.ClientStack return physicsPluginManager.GetPhysicsScene( engine ); } + protected Scene SetupScene(RegionInfo regionInfo, out UDPServer udpServer) + { + AgentCircuitManager authen = new AgentCircuitManager(); + udpServer = new UDPServer(regionInfo.InternalEndPoint.Port, m_assetCache, m_inventoryCache, m_log, authen); + + StorageManager storageManager = CreateStorageManager(regionInfo); + Scene scene = CreateScene(regionInfo, storageManager, authen); + + udpServer.LocalWorld = scene; + + scene.LoadStorageDLL("OpenSim.Region.Storage.LocalStorageDb4o.dll"); + scene.LoadWorldMap(); + + scene.PhysScene = GetPhysicsScene( ); + scene.PhysScene.SetTerrain(scene.Terrain.getHeights1D()); + scene.LoadPrimsFromStorage(); + + //Master Avatar Setup + UserProfileData masterAvatar = m_commsManager.UserServer.SetupMasterUser(scene.RegionInfo.MasterAvatarFirstName, scene.RegionInfo.MasterAvatarLastName, scene.RegionInfo.MasterAvatarSandboxPassword); + if (masterAvatar != null) + { + m_log.Notice("Parcels - Found master avatar [" + masterAvatar.UUID.ToStringHyphenated() + "]"); + scene.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID; + scene.localStorage.LoadLandObjects((ILocalStorageLandObjectReceiver)scene.LandManager); + } + else + { + m_log.Notice("Parcels - No master avatar found, using null."); + scene.RegionInfo.MasterAvatarAssignedUUID = libsecondlife.LLUUID.Zero; + scene.localStorage.LoadLandObjects((ILocalStorageLandObjectReceiver)scene.LandManager); + } + scene.performParcelPrimCountUpdate(); + scene.StartTimer(); + return scene; + } + + protected abstract Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager); } } diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs index 781f96aa31..ac17720818 100644 --- a/OpenSim/Region/ClientStack/UDPServer.cs +++ b/OpenSim/Region/ClientStack/UDPServer.cs @@ -56,7 +56,7 @@ namespace OpenSim.Region.ClientStack protected AssetCache m_assetCache; protected InventoryCache m_inventoryCache; protected LogBase m_log; - protected AuthenticateSessionsBase m_authenticateSessionsClass; + protected AgentCircuitManager m_authenticateSessionsClass; public PacketServer PacketServer { @@ -83,7 +83,7 @@ namespace OpenSim.Region.ClientStack { } - public UDPServer(int port, AssetCache assetCache, InventoryCache inventoryCache, LogBase console, AuthenticateSessionsBase authenticateClass) + public UDPServer(int port, AssetCache assetCache, InventoryCache inventoryCache, LogBase console, AgentCircuitManager authenticateClass) { listenPort = port; this.m_assetCache = assetCache; @@ -91,7 +91,6 @@ namespace OpenSim.Region.ClientStack this.m_log = console; this.m_authenticateSessionsClass = authenticateClass; this.CreatePacketServer(); - } protected virtual void CreatePacketServer() diff --git a/OpenSim/Region/Environment/RegionManager.cs b/OpenSim/Region/Environment/RegionManager.cs index f951701593..e75ee60ff1 100644 --- a/OpenSim/Region/Environment/RegionManager.cs +++ b/OpenSim/Region/Environment/RegionManager.cs @@ -10,7 +10,7 @@ namespace OpenSim.Region.Environment { public class RegionManager { - protected AuthenticateSessionsBase authenticateHandler; + protected AgentCircuitManager authenticateHandler; protected RegionCommsListener regionCommsHost; protected CommunicationsManager commsManager; protected List capsHandlers = new List(); diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index d2bb030698..671b222277 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -66,7 +66,7 @@ namespace OpenSim.Region.Environment.Scenes private int landPrimCheckCount; private Mutex updateLock; - protected AuthenticateSessionsBase authenticateHandler; + protected AgentCircuitManager authenticateHandler; protected RegionCommsListener regionCommsHost; protected CommunicationsManager commsManager; protected StorageManager storageManager; @@ -128,7 +128,7 @@ namespace OpenSim.Region.Environment.Scenes /// Dictionary to contain client threads /// Region Handle for this region /// Region Name for this region - public Scene(RegionInfo regInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer) + public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer) { updateLock = new Mutex(false); this.authenticateHandler = authen; diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs index 4fe3c7a1c8..cd69225603 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs @@ -18,7 +18,7 @@ namespace SimpleApp { private List m_avatars; - public MyWorld( RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeMan, BaseHttpServer httpServer) + public MyWorld( RegionInfo regionInfo, AgentCircuitManager authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeMan, BaseHttpServer httpServer) : base( regionInfo, authen, commsMan, assetCach, storeMan, httpServer) { m_avatars = new List(); diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index fe8c11a91d..c945d39dc2 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs @@ -22,9 +22,7 @@ namespace SimpleApp { class Program : RegionApplicationBase, conscmd_callback { - AuthenticateSessionsBase m_circuitManager; - - public MyWorld m_world; + public MyWorld m_scene; private SceneObject m_sceneObject; public MyNpcCharacter m_character; @@ -36,73 +34,52 @@ namespace SimpleApp protected override void Initialize() { m_httpServerPort = 9000; + + StartLog(); + + LocalAssetServer assetServer = new LocalAssetServer(); + assetServer.SetServerInfo("http://localhost:8003/", ""); + + AssetCache m_assetCache = new AssetCache(assetServer); } public void Run() { base.StartUp(); - m_circuitManager = new AuthenticateSessionsBase(); + CommunicationsLocal m_commsManager = new CommunicationsLocal(m_networkServersInfo, m_httpServer); - InventoryCache inventoryCache = new InventoryCache(); - - LocalAssetServer assetServer = new LocalAssetServer(); - assetServer.SetServerInfo("http://localhost:8003/", ""); - - AssetCache assetCache = new AssetCache(assetServer); - - ScenePresence.LoadTextureFile("avatar-texture.dat"); ScenePresence.PhysicsEngineFlying = true; IPEndPoint internalEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9000); RegionInfo regionInfo = new RegionInfo(1000, 1000, internalEndPoint, "localhost"); - UDPServer udpServer = new UDPServer(internalEndPoint.Port, assetCache, inventoryCache, m_log, m_circuitManager); - PacketServer packetServer = new PacketServer(udpServer); + UDPServer udpServer; - CommunicationsLocal communicationsManager = new CommunicationsLocal(m_networkServersInfo, m_httpServer); - - StorageManager storeMan = GetStoreManager(regionInfo); - - - - m_world = new MyWorld( regionInfo, m_circuitManager, communicationsManager, assetCache, storeMan, m_httpServer); - m_world.PhysScene = GetPhysicsScene( ); - - m_world.LoadWorldMap(); - m_world.PhysScene.SetTerrain(m_world.Terrain.getHeights1D()); - m_world.performParcelPrimCountUpdate(); - - udpServer.LocalWorld = m_world; - - m_httpServer.Start(); + Scene scene = SetupScene(regionInfo, out udpServer); + udpServer.ServerListener(); - - UserProfileData masterAvatar = communicationsManager.UserServer.SetupMasterUser("Test", "User", "test"); - if (masterAvatar != null) - { - m_world.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID; - m_world.LandManager.NoLandDataFromStorage(); - } - - m_world.StartTimer(); - + PrimitiveBaseShape shape = PrimitiveBaseShape.DefaultBox(); shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f); LLVector3 pos = new LLVector3(138, 129, 27); - m_sceneObject = new MySceneObject(m_world, m_world.EventManager, LLUUID.Zero, m_world.PrimIDAllocate(), pos, shape); - m_world.AddEntity(m_sceneObject); + m_sceneObject = new MySceneObject(scene, scene.EventManager, LLUUID.Zero, scene.PrimIDAllocate(), pos, shape); + scene.AddEntity(m_sceneObject); m_character = new MyNpcCharacter(); - m_world.AddNewClient(m_character, false); + scene.AddNewClient(m_character, false); m_log.WriteLine(LogPriority.NORMAL, "Press enter to quit."); - m_log.ReadLine(); - + m_log.ReadLine(); } - protected override StorageManager GetStoreManager(RegionInfo regionInfo) + protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager) + { + return new MyWorld(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer); + } + + protected override StorageManager CreateStorageManager(RegionInfo regionInfo) { return new StorageManager("OpenSim.DataStore.NullStorage.dll", "simpleapp.yap", "simpleapp"); } diff --git a/prebuild.xml b/prebuild.xml index a88b84bf2c..778271d412 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -639,6 +639,7 @@ +