From 564a97b508fd23601cd41075aa6a1f7de0800b41 Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 31 May 2007 15:31:31 +0000 Subject: [PATCH] Implementing a test Communications manager to test some of the interfaces (likely this test version will morph into the sandbox version) --- .../TestLocalCommsManager.cs | 17 ++++++----- Common/OpenSim.Framework/IRegionCommsHost.cs | 2 +- .../OpenSim.Framework/RegionCommsHostBase.cs | 4 +-- .../LocalUserProfileManager.cs | 4 +-- Common/OpenSim.Servers/LoginServer.cs | 5 ++-- OpenSim/OpenSim.World/OpenSim.World.csproj | 4 +++ OpenSim/OpenSim.World/World.cs | 29 ++++++++++++++++++- OpenSim/OpenSim/OpenSim.csproj | 4 +++ OpenSim/OpenSim/OpenSimMain.cs | 10 +++++-- 9 files changed, 60 insertions(+), 19 deletions(-) diff --git a/Common/OpenGrid.Framework.Communications/TestLocalCommsManager.cs b/Common/OpenGrid.Framework.Communications/TestLocalCommsManager.cs index 57049fc673..b4fe696065 100644 --- a/Common/OpenGrid.Framework.Communications/TestLocalCommsManager.cs +++ b/Common/OpenGrid.Framework.Communications/TestLocalCommsManager.cs @@ -11,8 +11,8 @@ namespace OpenGrid.Framework.Communications { public class TestLocalCommsManager : RegionServerCommsManager { - protected Dictionary regions = new Dictionary(); - protected Dictionary regionHosts = new Dictionary(); + protected Dictionary regions = new Dictionary(); + protected Dictionary regionHosts = new Dictionary(); public TestLocalCommsManager() { @@ -28,9 +28,9 @@ namespace OpenGrid.Framework.Communications { if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle)) { - this.regions.Add((uint)regionInfo.RegionHandle, regionInfo); + this.regions.Add(regionInfo.RegionHandle, regionInfo); RegionCommsHostBase regionHost = new RegionCommsHostBase(); - this.regionHosts.Add((uint)regionInfo.RegionHandle, regionHost); + this.regionHosts.Add(regionInfo.RegionHandle, regionHost); return regionHost; } @@ -59,13 +59,14 @@ namespace OpenGrid.Framework.Communications } /// - /// + /// Is a Sandbox mode method, used by the local Login server to inform a region of a connection user/session /// /// /// /// - public bool AddNewSession(uint regionHandle, Login loginData) + public bool AddNewSession(ulong regionHandle, Login loginData) { + Console.WriteLine(" comms manager been told to expect new user"); AgentCircuitData agent = new AgentCircuitData(); agent.AgentID = loginData.Agent; agent.firstname = loginData.First; @@ -77,9 +78,9 @@ namespace OpenGrid.Framework.Communications agent.InventoryFolder = loginData.InventoryFolder; agent.startpos = new LLVector3(128, 128, 70); - if (this.regionHosts.ContainsKey((uint)regionHandle)) + if (this.regionHosts.ContainsKey(regionHandle)) { - this.regionHosts[(uint)regionHandle].TriggerExpectUser(agent); + this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agent); return true; } diff --git a/Common/OpenSim.Framework/IRegionCommsHost.cs b/Common/OpenSim.Framework/IRegionCommsHost.cs index d115bb7438..c56383e1f5 100644 --- a/Common/OpenSim.Framework/IRegionCommsHost.cs +++ b/Common/OpenSim.Framework/IRegionCommsHost.cs @@ -6,7 +6,7 @@ using OpenSim.Framework.Types; namespace OpenSim.Framework { - public delegate void ExpectUserDelegate(AgentCircuitData agent); + public delegate void ExpectUserDelegate(ulong regionHandle, AgentCircuitData agent); public delegate void UpdateNeighbours(List neighbours); public interface IRegionCommsHost diff --git a/Common/OpenSim.Framework/RegionCommsHostBase.cs b/Common/OpenSim.Framework/RegionCommsHostBase.cs index 782755e264..41babe7c99 100644 --- a/Common/OpenSim.Framework/RegionCommsHostBase.cs +++ b/Common/OpenSim.Framework/RegionCommsHostBase.cs @@ -18,11 +18,11 @@ namespace OpenSim.Framework /// /// /// - public virtual bool TriggerExpectUser(AgentCircuitData agent) + public virtual bool TriggerExpectUser(ulong regionHandle, AgentCircuitData agent) { if(OnExpectUser != null) { - OnExpectUser(agent); + OnExpectUser(regionHandle, agent); return true; } diff --git a/Common/OpenSim.Servers/LocalUserProfileManager.cs b/Common/OpenSim.Servers/LocalUserProfileManager.cs index a8b5f1f249..99c640a022 100644 --- a/Common/OpenSim.Servers/LocalUserProfileManager.cs +++ b/Common/OpenSim.Servers/LocalUserProfileManager.cs @@ -116,8 +116,8 @@ namespace OpenSim.UserServer Console.WriteLine("adding login data to gridserver"); ((LocalGridBase)this.m_gridServer).AddNewSession(_login); }*/ - - this.AddSession(_login); + ulong reghand = Helpers.UIntsToLong((regionX * 256), (regionY * 256)); + this.AddSession(reghand, _login); } } } diff --git a/Common/OpenSim.Servers/LoginServer.cs b/Common/OpenSim.Servers/LoginServer.cs index 6fd174bdea..d02c41ee91 100644 --- a/Common/OpenSim.Servers/LoginServer.cs +++ b/Common/OpenSim.Servers/LoginServer.cs @@ -47,7 +47,7 @@ using OpenSim.Framework.Types; namespace OpenSim.UserServer { - public delegate void AddNewSessionHandler(Login loginData); + public delegate bool AddNewSessionHandler(ulong regionHandle, Login loginData); /// /// When running in local (default) mode , handles client logins. /// @@ -196,7 +196,8 @@ namespace OpenSim.UserServer { ((LocalGridBase)m_gridServer).AddNewSession(_login); }*/ - AddSession(_login); + ulong reghand = Helpers.UIntsToLong((regionX * 256), (regionY * 256)); + AddSession(reghand,_login); return response; } diff --git a/OpenSim/OpenSim.World/OpenSim.World.csproj b/OpenSim/OpenSim.World/OpenSim.World.csproj index 37293e19c1..78025d3603 100644 --- a/OpenSim/OpenSim.World/OpenSim.World.csproj +++ b/OpenSim/OpenSim.World/OpenSim.World.csproj @@ -87,6 +87,10 @@ + + {C9702041-922C-452A-A1B4-7880AF53149A} + OpenGrid.Framework.Communications + OpenSim.Terrain.BasicTerrain {2270B8FE-0000-0000-0000-000000000000} diff --git a/OpenSim/OpenSim.World/World.cs b/OpenSim/OpenSim.World/World.cs index c731dbc50a..69d46465a5 100644 --- a/OpenSim/OpenSim.World/World.cs +++ b/OpenSim/OpenSim.World/World.cs @@ -14,6 +14,7 @@ using OpenSim.Framework.Inventory; using OpenSim.Framework; using OpenSim.RegionServer.world.scripting; using OpenSim.Terrain; +using OpenGrid.Framework.Communications; namespace OpenSim.world { @@ -36,6 +37,8 @@ namespace OpenSim.world private Mutex updateLock; public string m_datastore; protected AuthenticateSessionsBase authenticateHandler; + protected RegionCommsHostBase regionCommsHost; + protected RegionServerCommsManager commsManager; #region Properties /// @@ -61,17 +64,19 @@ namespace OpenSim.world /// Dictionary to contain client threads /// Region Handle for this region /// Region Name for this region - public World(Dictionary clientThreads, RegionInfo regInfo, AuthenticateSessionsBase authen) + public World(Dictionary clientThreads, RegionInfo regInfo, AuthenticateSessionsBase authen, RegionServerCommsManager commsMan) { try { updateLock = new Mutex(false); this.authenticateHandler = authen; + this.commsManager = commsMan; m_clientThreads = clientThreads; m_regInfo = regInfo; m_regionHandle = m_regInfo.RegionHandle; m_regionName = m_regInfo.RegionName; this.m_datastore = m_regInfo.DataStore; + this.RegisterRegionWithComms(); m_scriptHandlers = new Dictionary(); m_scripts = new Dictionary(); @@ -540,5 +545,27 @@ namespace OpenSim.world } #endregion + #region RegionCommsHost + + public void RegisterRegionWithComms() + { + this.regionCommsHost = this.commsManager.RegisterRegion(this.m_regInfo); + if (this.regionCommsHost != null) + { + this.regionCommsHost.OnExpectUser += new ExpectUserDelegate(this.NewUserConnection); + } + } + + public void NewUserConnection(ulong regionHandle,AgentCircuitData agent) + { + Console.WriteLine("World.cs - add new user connection"); + //should just check that its meant for this region + if (regionHandle == this.m_regInfo.RegionHandle) + { + this.authenticateHandler.AddNewCircuit(agent.circuitcode, agent); + } + } + + #endregion } } diff --git a/OpenSim/OpenSim/OpenSim.csproj b/OpenSim/OpenSim/OpenSim.csproj index 79abd9ea9d..03ae6abae4 100644 --- a/OpenSim/OpenSim/OpenSim.csproj +++ b/OpenSim/OpenSim/OpenSim.csproj @@ -87,6 +87,10 @@ + + {C9702041-922C-452A-A1B4-7880AF53149A} + OpenGrid.Framework.Communications + OpenSim.Terrain.BasicTerrain {2270B8FE-0000-0000-0000-000000000000} diff --git a/OpenSim/OpenSim/OpenSimMain.cs b/OpenSim/OpenSim/OpenSimMain.cs index 4aa48bdfbc..66aadb0852 100644 --- a/OpenSim/OpenSim/OpenSimMain.cs +++ b/OpenSim/OpenSim/OpenSimMain.cs @@ -51,6 +51,7 @@ using OpenSim.Physics.Manager; using Nwc.XmlRpc; using OpenSim.Servers; using OpenSim.GenericConfig; +using OpenGrid.Framework.Communications; namespace OpenSim { @@ -58,6 +59,7 @@ namespace OpenSim public class OpenSimMain : RegionServerBase, conscmd_callback { private CheckSumServer checkServer; + protected RegionServerCommsManager commsManager; public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile) { @@ -101,10 +103,12 @@ namespace OpenSim this.SetupLocalGridServers(); this.checkServer = new CheckSumServer(12036); this.checkServer.ServerListener(); + this.commsManager = new TestLocalCommsManager(); } else { this.SetupRemoteGridServers(); + this.commsManager = new TestLocalCommsManager(); //should be a remote comms manager class } startuptime = DateTime.Now; @@ -126,8 +130,8 @@ namespace OpenSim { loginServer = new LoginServer(regionData[0].IPListenAddr, regionData[0].IPListenPort, regionData[0].RegionLocX, regionData[0].RegionLocY, false); loginServer.Startup(); - loginServer.SetSessionHandler(((AuthenticateSessionsLocal)this.AuthenticateSessionsHandler[0]).AddNewSession); - + //loginServer.SetSessionHandler(((AuthenticateSessionsLocal)this.AuthenticateSessionsHandler[0]).AddNewSession); + loginServer.SetSessionHandler(((TestLocalCommsManager)this.commsManager).AddNewSession); //sandbox mode with loginserver not using accounts httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod); } @@ -234,7 +238,7 @@ namespace OpenSim m_console.componentname = "Region " + regionData.RegionName; */ - LocalWorld = new World(udpServer.PacketServer.ClientAPIs, regionDat, authenBase); + LocalWorld = new World(udpServer.PacketServer.ClientAPIs, regionDat, authenBase, commsManager); this.m_localWorld.Add(LocalWorld); //LocalWorld.InventoryCache = InventoryCache; //LocalWorld.AssetCache = AssetCache;