diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index 4853c3a2d5..a1afe8dc8f 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -34,6 +34,6 @@ namespace OpenSim.Framework.Communications { bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying); - bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentID); + bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId); } } diff --git a/OpenSim/Framework/General/ClientManager.cs b/OpenSim/Framework/General/ClientManager.cs index b0328496f6..7cf0aeac58 100644 --- a/OpenSim/Framework/General/ClientManager.cs +++ b/OpenSim/Framework/General/ClientManager.cs @@ -100,5 +100,10 @@ namespace OpenSim.Framework } } } + + public bool TryGetClient(uint circuitId, out IClientAPI user) + { + return m_clients.TryGetValue(circuitId, out user); + } } } diff --git a/OpenSim/Framework/General/Configuration/ConfigurationMember.cs b/OpenSim/Framework/General/Configuration/ConfigurationMember.cs index e4c13ba12e..e421ba54c1 100644 --- a/OpenSim/Framework/General/Configuration/ConfigurationMember.cs +++ b/OpenSim/Framework/General/Configuration/ConfigurationMember.cs @@ -116,7 +116,6 @@ namespace OpenSim.Framework.Configuration configurationPlugin.LoadData(); useFile = true; } - else { MainLog.Instance.Notice("XML Configuration Filename is not valid; will not save to the file."); diff --git a/OpenSim/Framework/General/Interfaces/IScene.cs b/OpenSim/Framework/General/Interfaces/IScene.cs index 6140918925..e3e65f14fb 100644 --- a/OpenSim/Framework/General/Interfaces/IScene.cs +++ b/OpenSim/Framework/General/Interfaces/IScene.cs @@ -38,5 +38,10 @@ namespace OpenSim.Framework.Interfaces RegionInfo RegionInfo { get; } object SyncRoot { get; } uint NextLocalId { get; } + + ClientManager ClientManager + { + get; + } } } diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs index 7134ad37bc..6fd4ba41b8 100644 --- a/OpenSim/Region/ClientStack/PacketServer.cs +++ b/OpenSim/Region/ClientStack/PacketServer.cs @@ -40,12 +40,13 @@ namespace OpenSim.Region.ClientStack public class PacketServer { private ClientStackNetworkHandler m_networkHandler; - private IScene _localScene; - private readonly ClientManager m_clientManager = new ClientManager(); - public ClientManager ClientManager - { - get { return m_clientManager; } - } + private IScene m_scene; + + //private readonly ClientManager m_clientManager = new ClientManager(); + //public ClientManager ClientManager + //{ + // get { return m_clientManager; } + //} public PacketServer(ClientStackNetworkHandler networkHandler) { @@ -57,7 +58,7 @@ namespace OpenSim.Region.ClientStack { set { - this._localScene = value; + this.m_scene = value; } } @@ -68,7 +69,7 @@ namespace OpenSim.Region.ClientStack /// public virtual void InPacket(uint circuitCode, Packet packet) { - m_clientManager.InPacket(circuitCode, packet); + m_scene.ClientManager.InPacket(circuitCode, packet); } protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions) @@ -76,28 +77,27 @@ namespace OpenSim.Region.ClientStack return new ClientView(remoteEP, initialcirpack, clientManager, scene, assetCache, packServer, authenSessions ); } - /// - /// - /// - /// - /// - /// - /// - /// - /// public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, AgentCircuitManager authenticateSessionsClass) { - IClientAPI newuser = - CreateNewClient(epSender, useCircuit, m_clientManager, _localScene, assetCache, this, - authenticateSessionsClass); + IClientAPI newuser; - this.m_clientManager.Add(useCircuit.CircuitCode.Code, newuser); + if (m_scene.ClientManager.TryGetClient(useCircuit.CircuitCode.Code, out newuser)) + { + return false; + } + else + { + newuser = CreateNewClient(epSender, useCircuit, m_scene.ClientManager, m_scene, assetCache, this, + authenticateSessionsClass); - newuser.OnViewerEffect += m_clientManager.ViewerEffectHandler; - newuser.OnLogout += LogoutHandler; - newuser.OnConnectionClosed += CloseClient; + m_scene.ClientManager.Add(useCircuit.CircuitCode.Code, newuser); - return true; + newuser.OnViewerEffect += m_scene.ClientManager.ViewerEffectHandler; + newuser.OnLogout += LogoutHandler; + newuser.OnConnectionClosed += CloseClient; + + return true; + } } public void LogoutHandler(IClientAPI client) @@ -127,7 +127,7 @@ namespace OpenSim.Region.ClientStack public virtual void CloseCircuit(uint circuitcode) { m_networkHandler.RemoveClientCircuit( circuitcode ); - m_clientManager.CloseAllAgents( circuitcode ); + m_scene.ClientManager.CloseAllAgents(circuitcode); } public virtual void CloseClient( IClientAPI client ) diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs index 3e23963ea3..9a6bc82def 100644 --- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs +++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs @@ -30,14 +30,15 @@ using libsecondlife; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Types; +using System.Collections; namespace OpenSim.Region.Communications.Local { public class LocalBackEndServices : IGridServices, IInterRegionCommunications { - protected Dictionary regions = new Dictionary(); - protected Dictionary regionHosts = new Dictionary(); + protected Dictionary m_regions = new Dictionary(); + protected Dictionary m_regionListeners = new Dictionary(); public LocalBackEndServices() { @@ -52,12 +53,13 @@ namespace OpenSim.Region.Communications.Local public RegionCommsListener RegisterRegion(RegionInfo regionInfo) { //Console.WriteLine("CommsManager - Region " + regionInfo.RegionHandle + " , " + regionInfo.RegionLocX + " , "+ regionInfo.RegionLocY +" is registering"); - if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle)) + if (!this.m_regions.ContainsKey((uint)regionInfo.RegionHandle)) { //Console.WriteLine("CommsManager - Adding Region " + regionInfo.RegionHandle ); - this.regions.Add(regionInfo.RegionHandle, regionInfo); + this.m_regions.Add(regionInfo.RegionHandle, regionInfo); + RegionCommsListener regionHost = new RegionCommsListener(); - this.regionHosts.Add(regionInfo.RegionHandle, regionHost); + this.m_regionListeners.Add(regionInfo.RegionHandle, regionHost); return regionHost; } @@ -75,7 +77,7 @@ namespace OpenSim.Region.Communications.Local // Console.WriteLine("Finding Neighbours to " + regionInfo.RegionHandle); List neighbours = new List(); - foreach (RegionInfo reg in this.regions.Values) + foreach (RegionInfo reg in this.m_regions.Values) { // Console.WriteLine("CommsManager- RequestNeighbours() checking region " + reg.RegionLocX + " , "+ reg.RegionLocY); if (reg.RegionHandle != regionInfo.RegionHandle) @@ -100,9 +102,9 @@ namespace OpenSim.Region.Communications.Local /// public RegionInfo RequestNeighbourInfo(ulong regionHandle) { - if (this.regions.ContainsKey(regionHandle)) + if (this.m_regions.ContainsKey(regionHandle)) { - return this.regions[regionHandle]; + return this.m_regions[regionHandle]; } return null; } @@ -118,7 +120,7 @@ namespace OpenSim.Region.Communications.Local public List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY) { List mapBlocks = new List(); - foreach(RegionInfo regInfo in this.regions.Values) + foreach(RegionInfo regInfo in this.m_regions.Values) { if (((regInfo.RegionLocX >= minX) && (regInfo.RegionLocX <= maxX)) && ((regInfo.RegionLocY >= minY) && (regInfo.RegionLocY <= maxY))) { @@ -145,10 +147,10 @@ namespace OpenSim.Region.Communications.Local public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) //should change from agentCircuitData { //Console.WriteLine("CommsManager- Trying to Inform a region to expect child agent"); - if (this.regionHosts.ContainsKey(regionHandle)) + if (this.m_regionListeners.ContainsKey(regionHandle)) { // Console.WriteLine("CommsManager- Informing a region to expect child agent"); - this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agentData); + this.m_regionListeners[regionHandle].TriggerExpectUser(regionHandle, agentData); return true; } return false; @@ -163,18 +165,18 @@ namespace OpenSim.Region.Communications.Local /// public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) { - if (this.regionHosts.ContainsKey(regionHandle)) + if (this.m_regionListeners.ContainsKey(regionHandle)) { // Console.WriteLine("CommsManager- Informing a region to expect avatar crossing"); - this.regionHosts[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying); + this.m_regionListeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying); return true; } return false; } - public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentID) + public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId) { - if (this.regionHosts.ContainsKey(regionHandle)) + if (this.m_regionListeners.ContainsKey(regionHandle)) { return true; } @@ -201,11 +203,54 @@ namespace OpenSim.Region.Communications.Local agent.startpos = new LLVector3(128, 128, 70); agent.CapsPath = loginData.CapsPath; - if (this.regionHosts.ContainsKey(regionHandle)) + TriggerExpectUser(regionHandle, agent); + } + + public void TriggerExpectUser(ulong regionHandle, AgentCircuitData agent) + { + if (this.m_regionListeners.ContainsKey(regionHandle)) { - this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agent); + this.m_regionListeners[regionHandle].TriggerExpectUser(regionHandle, agent); } } + + public void PingCheckReply(Hashtable respData) + { + foreach (ulong region in this.m_regions.Keys ) + { + Hashtable regData = new Hashtable(); + RegionInfo reg = m_regions[region]; + regData["status"] = "active"; + regData["handle"] = region.ToString(); + + respData[reg.SimUUID.ToStringHyphenated()] = regData; + } + } + + public bool TriggerExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) + { + if ( m_regionListeners.ContainsKey(regionHandle)) + { + return m_regionListeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position, + isFlying); + } + + return false; + } + + public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) + { + if (m_regionListeners.ContainsKey(regionHandle)) + { + TriggerExpectUser(regionHandle, agentData); + return true; + } + + return false; + } + + + } } diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 91694b5ff4..1b4b54c72d 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -12,13 +12,13 @@ using OpenSim.Framework.Communications; using OpenSim.Framework.Console; using OpenSim.Framework.Servers; using OpenSim.Framework.Types; +using OpenSim.Region.Communications.Local; namespace OpenSim.Region.Communications.OGS1 { public class OGS1GridServices : IGridServices, IInterRegionCommunications { - public Dictionary listeners = new Dictionary(); - protected Dictionary regions = new Dictionary(); + private LocalBackEndServices m_localBackend = new LocalBackEndServices(); public BaseHttpServer httpListener; public NetworkServersInfo serversInfo; @@ -35,6 +35,7 @@ namespace OpenSim.Region.Communications.OGS1 httpServer = httpServe; httpServer.AddXmlRPCHandler("expect_user", this.ExpectUser); httpServer.AddXmlRPCHandler("check", this.PingCheckReply); + this.StartRemoting(); } @@ -45,11 +46,6 @@ namespace OpenSim.Region.Communications.OGS1 /// public RegionCommsListener RegisterRegion(RegionInfo regionInfo) { - if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle)) - { - this.regions.Add(regionInfo.RegionHandle, regionInfo); - } - Hashtable GridParams = new Hashtable(); // Login / Authentication @@ -83,18 +79,7 @@ namespace OpenSim.Region.Communications.OGS1 return null; } - // Initialise the background listeners - RegionCommsListener regListener = new RegionCommsListener(); - if (!this.listeners.ContainsKey(regionInfo.RegionHandle)) - { - this.listeners.Add(regionInfo.RegionHandle, regListener); - } - else - { - listeners[regionInfo.RegionHandle] = regListener; - } - - return regListener; + return m_localBackend.RegisterRegion(regionInfo); } /// @@ -133,7 +118,7 @@ namespace OpenSim.Region.Communications.OGS1 neighbour.RegionName = (string)neighbourData["name"]; //OGS1+ - neighbour.SimUUID = new LLUUID((string) neighbourData["uuid"]); + neighbour.SimUUID = new LLUUID((string)neighbourData["uuid"]); neighbours.Add(neighbour); } @@ -150,9 +135,11 @@ namespace OpenSim.Region.Communications.OGS1 /// public RegionInfo RequestNeighbourInfo(ulong regionHandle) { - if (this.regions.ContainsKey(regionHandle)) + RegionInfo regionInfo = m_localBackend.RequestNeighbourInfo(regionHandle); + + if (regionInfo != null) { - return this.regions[regionHandle]; + return regionInfo; } Hashtable requestData = new Hashtable(); @@ -179,7 +166,7 @@ namespace OpenSim.Region.Communications.OGS1 IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port); string neighbourExternalUri = externalUri; - RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); + regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); regionInfo.RemotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); regionInfo.RemotingAddress = internalIpStr; @@ -245,7 +232,7 @@ namespace OpenSim.Region.Communications.OGS1 IList parameters = new ArrayList(); parameters.Add(param); XmlRpcRequest req = new XmlRpcRequest("map_block", parameters); - XmlRpcResponse resp = req.Send(serversInfo.GridURL, 3000); + XmlRpcResponse resp = req.Send(serversInfo.GridURL, 10000); Hashtable respData = (Hashtable)resp.Value; return respData; } @@ -262,15 +249,7 @@ namespace OpenSim.Region.Communications.OGS1 Hashtable respData = new Hashtable(); respData["online"] = "true"; - foreach (ulong region in this.listeners.Keys) - { - Hashtable regData = new Hashtable(); - RegionInfo reg = regions[region]; - regData["status"] = "active"; - regData["handle"] = region.ToString(); - - respData[reg.SimUUID.ToStringHyphenated()] = regData; - } + m_localBackend.PingCheckReply(respData); response.Value = respData; @@ -308,14 +287,9 @@ namespace OpenSim.Region.Communications.OGS1 } - if (listeners.ContainsKey(Convert.ToUInt64((string)requestData["regionhandle"]))) - { - this.listeners[Convert.ToUInt64((string)requestData["regionhandle"])].TriggerExpectUser(Convert.ToUInt64((string)requestData["regionhandle"]), agentData); - } - else - { - MainLog.Instance.Error("ExpectUser() - Unknown region " + (Convert.ToUInt64(requestData["regionhandle"])).ToString()); - } + ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]); + + m_localBackend.TriggerExpectUser(regionHandle, agentData); MainLog.Instance.Verbose("ExpectUser() - Welcoming new user..."); @@ -333,7 +307,7 @@ namespace OpenSim.Region.Communications.OGS1 WellKnownServiceTypeEntry wellType = new WellKnownServiceTypeEntry(typeof(OGS1InterRegionRemoting), "InterRegions", WellKnownObjectMode.Singleton); RemotingConfiguration.RegisterWellKnownServiceType(wellType); - InterRegionSingleton.Instance.OnArrival += this.IncomingArrival; + InterRegionSingleton.Instance.OnArrival += this.TriggerExpectAvatarCrossing; InterRegionSingleton.Instance.OnChildAgent += this.IncomingChildAgent; } @@ -348,11 +322,11 @@ namespace OpenSim.Region.Communications.OGS1 { try { - if (this.listeners.ContainsKey(regionHandle)) + if (m_localBackend.InformRegionOfChildAgent(regionHandle, agentData)) { - this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData); return true; } + RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle); if (regInfo != null) { @@ -401,11 +375,11 @@ namespace OpenSim.Region.Communications.OGS1 { try { - if (this.listeners.ContainsKey(regionHandle)) + if (m_localBackend.TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying)) { - this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying); return true; } + RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle); if (regInfo != null) { @@ -440,14 +414,11 @@ namespace OpenSim.Region.Communications.OGS1 } } - public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentID) + public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId) { - if (this.listeners.ContainsKey(regionHandle)) - { - return true; - } - return false; + return m_localBackend.AcknowledgeAgentCrossed(regionHandle, agentId); } + #endregion #region Methods triggered by calls from external instances @@ -461,17 +432,13 @@ namespace OpenSim.Region.Communications.OGS1 { try { - if (this.listeners.ContainsKey(regionHandle)) - { - this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData); - return true; - } + return m_localBackend.IncomingChildAgent(regionHandle, agentData); } catch (System.Runtime.Remoting.RemotingException e) { MainLog.Instance.Error("Remoting Error: Unable to connect to remote region.\n" + e.ToString()); + return false; } - return false; } /// @@ -481,21 +448,18 @@ namespace OpenSim.Region.Communications.OGS1 /// /// /// - public bool IncomingArrival(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) + public bool TriggerExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) { + try { - if (this.listeners.ContainsKey(regionHandle)) - { - this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying); - return true; - } + return m_localBackend.TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying); } catch (System.Runtime.Remoting.RemotingException e) { MainLog.Instance.Error("Remoting Error: Unable to connect to remote region.\n" + e.ToString()); + return false; } - return false; } #endregion #endregion diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 5fbe9183f5..7381930aa4 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -54,7 +54,6 @@ namespace OpenSim.Region.Environment.Scenes { public partial class Scene : SceneBase { - public delegate bool FilterAvatarList(ScenePresence avatar); protected Timer m_heartbeatTimer = new Timer(); diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index b3cd99cc14..96321c7926 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs @@ -33,11 +33,18 @@ using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Region.Terrain; +using OpenSim.Framework; namespace OpenSim.Region.Environment.Scenes { public abstract class SceneBase : IScene { + private readonly ClientManager m_clientManager = new ClientManager(); + public ClientManager ClientManager + { + get { return m_clientManager; } + } + public Dictionary Entities; protected ulong m_regionHandle; protected string m_regionName;