From 73fbacea1fe18873fab175d82189a1becb0f8e10 Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 5 Nov 2007 13:58:44 +0000 Subject: Started to cleanup/close down childagent connections when a user teleports. As the client will not close old childagent connections without being told explicitly to do so by each region the connection is to. Currently only implemented in standalone mode. ( the TellRegionToCloseChildConnection( ) in OGS1GridServices.cs needs implementing for grid mode, and the inter region .net remoting added for the new messages). hopefully fixed the echo bug in chatmodule. --- OpenSim/Region/Environment/Scenes/Scene.cs | 20 ++++++++++-- .../Scenes/SceneCommunicationService.cs | 37 ++++++++++++++++++---- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 16 ++++++++-- .../Region/Environment/Scenes/SceneXmlLoader.cs | 2 +- 4 files changed, 61 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes') diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 8262478..d436bb3 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -816,6 +816,7 @@ namespace OpenSim.Region.Environment.Scenes m_sceneGridService.RegisterRegion(m_regInfo); m_sceneGridService.OnExpectUser += NewUserConnection; m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing; + m_sceneGridService.OnCloseAgentConnection += CloseConnection; } /// @@ -864,13 +865,26 @@ namespace OpenSim.Region.Environment.Scenes } } + public void CloseConnection(ulong regionHandle, LLUUID agentID) + { + if (regionHandle == m_regionHandle) + { + ScenePresence presence = m_innerScene.GetScenePresence(agentID); + if(presence != null) + { + libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket(); + presence.ControllingClient.OutPacket(disable); + } + } + } + /// /// /// public void InformClientOfNeighbours(ScenePresence presence) { - m_sceneGridService.InformClientOfNeighbours(presence); + m_sceneGridService.EnableNeighbourChildAgents(presence); } /// @@ -908,7 +922,7 @@ namespace OpenSim.Region.Environment.Scenes { if (m_scenePresences.ContainsKey(remoteClient.AgentId)) { - m_sceneGridService.RequestTeleportLocation(m_scenePresences[remoteClient.AgentId], regionHandle, position, lookAt, flags); + m_sceneGridService.RequestTeleportToLocation(m_scenePresences[remoteClient.AgentId], regionHandle, position, lookAt, flags); } } @@ -920,7 +934,7 @@ namespace OpenSim.Region.Environment.Scenes /// public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position, bool isFlying) { - return m_sceneGridService.InformNeighbourOfCrossing(regionhandle, agentID, position, isFlying); + return m_sceneGridService.CrossToNeighbouringRegion(regionhandle, agentID, position, isFlying); } #endregion diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index 27b0cba..9bd55e1 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -19,7 +19,7 @@ namespace OpenSim.Region.Environment.Scenes public event AgentCrossing OnAvatarCrossingIntoRegion; public event ExpectUserDelegate OnExpectUser; - + public event CloseAgentConnection OnCloseAgentConnection; public SceneCommunicationService(CommunicationsManager commsMan) { @@ -34,6 +34,7 @@ namespace OpenSim.Region.Environment.Scenes { regionCommsHost.OnExpectUser += NewUserConnection; regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; + regionCommsHost.OnCloseAgentConnection += CloseConnection; } } @@ -41,6 +42,7 @@ namespace OpenSim.Region.Environment.Scenes { regionCommsHost.OnExpectUser -= NewUserConnection; regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; + regionCommsHost.OnCloseAgentConnection -= CloseConnection; //regionCommsHost.RemoveRegion(m_regionInfo); //TODO add to method to commsManager regionCommsHost = null; } @@ -51,7 +53,7 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void NewUserConnection(ulong regionHandle, AgentCircuitData agent) + protected void NewUserConnection(ulong regionHandle, AgentCircuitData agent) { if (OnExpectUser != null) { @@ -59,13 +61,21 @@ namespace OpenSim.Region.Environment.Scenes } } - public void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) + protected void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) { if (OnAvatarCrossingIntoRegion != null) { OnAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying); } } + + protected void CloseConnection(ulong regionHandle, LLUUID agentID) + { + if (OnCloseAgentConnection != null) + { + OnCloseAgentConnection(regionHandle, agentID); + } + } #endregion #region Inform Client of Neighbours @@ -105,7 +115,7 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void InformClientOfNeighbours(ScenePresence avatar) + public void EnableNeighbourChildAgents(ScenePresence avatar) { List neighbours = m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); @@ -160,7 +170,7 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public virtual void RequestTeleportLocation(ScenePresence avatar, ulong regionHandle, LLVector3 position, + public virtual void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags) { if (regionHandle == m_regionInfo.RegionHandle) @@ -189,6 +199,14 @@ namespace OpenSim.Region.Environment.Scenes string capsPath = Util.GetCapsURL(avatar.ControllingClient.AgentId); avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), capsPath); avatar.MakeChildAgent(); + uint newRegionX = (uint)(regionHandle >> 40); + uint newRegionY = (((uint)(regionHandle)) >> 8); + uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40); + uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8); + if (Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3) + { + CloseChildAgentConnections(avatar); + } } } } @@ -199,14 +217,19 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position, bool isFlying) + public bool CrossToNeighbouringRegion(ulong regionhandle, LLUUID agentID, LLVector3 position, bool isFlying) { return m_commsProvider.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position, isFlying); } public void CloseChildAgentConnections(ScenePresence presence) { - + foreach (ulong regionHandle in presence.KnownChildRegions) + { + + m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, presence.ControllingClient.AgentId); + presence.RemoveNeighbourRegion(regionHandle); + } } } } diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 628921c..49e3c39 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -232,6 +232,10 @@ namespace OpenSim.Region.Environment.Scenes set { m_parentID = value; } } + public List KnownChildRegions + { + get { return m_KnownChildRegions; } + } #endregion #region Constructor(s) @@ -411,6 +415,13 @@ namespace OpenSim.Region.Environment.Scenes } } + public void RemoveNeighbourRegion(ulong regionHandle) + { + if (!m_KnownChildRegions.Contains(regionHandle)) + { + m_KnownChildRegions.Remove(regionHandle); + } + } #endregion #region Event Handlers @@ -1090,9 +1101,8 @@ namespace OpenSim.Region.Environment.Scenes public void SetWearable(int wearableId, AvatarWearable wearable) { m_wearables[wearableId] = wearable; - m_controllingClient.SendWearables(m_wearables, m_wearablesSerial++); - SendOurAppearance( m_controllingClient ); - + m_controllingClient.SendWearables(m_wearables, ++m_wearablesSerial); + //m_controllingClient.SendWearables(m_wearables, m_wearablesSerial++); } } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs index 1176e13..e0ddec5 100644 --- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs +++ b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs @@ -10,7 +10,7 @@ using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Environment.Scenes { - public class SceneXmlLoader //Most likely can move to a module + public class SceneXmlLoader // can move to a module? { protected InnerScene m_innerScene; protected RegionInfo m_regInfo; -- cgit v1.1