* RegionApplicationBase restructuring now complete

* Still has some weird bug in SimpleApp though.
afrisby
lbsa71 2007-07-16 23:25:35 +00:00
parent 6c9d9b660d
commit 497ab5d7ab
11 changed files with 100 additions and 127 deletions

View File

@ -32,11 +32,11 @@ using OpenSim.Framework.Types;
namespace OpenSim.Framework
{
public class AuthenticateSessionsBase
public class AgentCircuitManager
{
public Dictionary<uint, AgentCircuitData> AgentCircuits = new Dictionary<uint, AgentCircuitData>();
public AuthenticateSessionsBase()
public AgentCircuitManager()
{
}

View File

@ -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<UDPServer> m_udpServers = new List<UDPServer>();
protected List<RegionInfo> m_regionData = new List<RegionInfo>();
protected List<IWorld> m_localWorld = new List<IWorld>();
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");
@ -130,59 +129,14 @@ namespace OpenSim
regionConfig.Close();
UDPServer udpServer;
Scene scene = SetupScene(regionInfo, out udpServer);
AuthenticateSessionsBase authenBase;
m_localWorld.Add(scene);
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()

View File

@ -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<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions )
public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AgentCircuitManager authenSessions )
{
m_world = world;
m_clientThreads = clientThreads;

View File

@ -133,7 +133,7 @@ namespace OpenSim.Region.ClientStack
/// <param name="inventoryCache"></param>
/// <param name="authenSessions"></param>
/// <returns></returns>
protected virtual ClientView CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions)
protected virtual ClientView CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> 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
/// <param name="inventoryCache"></param>
/// <param name="authenticateSessionsClass"></param>
/// <returns></returns>
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,

View File

@ -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<UDPServer> m_udpServers = new List<UDPServer>();
protected List<RegionInfo> m_regionData = new List<RegionInfo>();
protected List<IWorld> m_localWorld = new List<IWorld>();
protected BaseHttpServer m_httpServer;
protected int m_httpServerPort;
protected List<AuthenticateSessionsBase> AuthenticateSessionsHandler = new List<AuthenticateSessionsBase>();
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);
}
}

View File

@ -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()

View File

@ -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<Caps> capsHandlers = new List<Caps>();

View File

@ -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
/// <param name="clientThreads">Dictionary to contain client threads</param>
/// <param name="regionHandle">Region Handle for this region</param>
/// <param name="regionName">Region Name for this region</param>
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;

View File

@ -18,7 +18,7 @@ namespace SimpleApp
{
private List<ScenePresence> 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<Avatar>();

View File

@ -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);
Scene scene = SetupScene(regionInfo, out udpServer);
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();
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();
}
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");
}

View File

@ -639,6 +639,7 @@
<Reference name="OpenSim.Region.Environment"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Region.Physics.Manager"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Region.Caches"/>