From 1b1f0a2d77fb4d2ac572f16c71a7560860c8c040 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 12 Jun 2012 02:43:33 +0100 Subject: OnConnectionClosed listeners, retrieve data from IClientAPI.SceneAgent rather than scanning all scene for the presence with the right id Stop checking IsLoggingOut on these listeners, if called with a root agent then we always want to perform these actions. This covers cases where the client is closed due to manual kick, simulator shutdown, etc. --- OpenSim/Framework/ISceneAgent.cs | 7 ++++ .../EntityTransfer/HGEntityTransferModule.cs | 46 ++++++++++------------ .../GridUser/ActivityDetector.cs | 28 +++---------- .../Presence/PresenceDetector.cs | 2 +- .../Framework/Scenes/AsyncInventorySender.cs | 2 +- .../SimianGrid/SimianActivityDetector.cs | 28 ++++--------- 6 files changed, 43 insertions(+), 70 deletions(-) diff --git a/OpenSim/Framework/ISceneAgent.cs b/OpenSim/Framework/ISceneAgent.cs index 824172d..563d906 100644 --- a/OpenSim/Framework/ISceneAgent.cs +++ b/OpenSim/Framework/ISceneAgent.cs @@ -26,6 +26,7 @@ */ using System; +using OpenMetaverse; namespace OpenSim.Framework { @@ -71,5 +72,11 @@ namespace OpenSim.Framework /// This includes scene object data and the appearance data of other avatars. /// void SendInitialDataToMe(); + + /// + /// Direction in which the scene presence is looking. + /// + /// Will be Vector3.Zero for a child agent. + Vector3 Lookat { get; } } } \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 43a72e2..08863c2 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -325,34 +325,30 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer void OnConnectionClosed(IClientAPI obj) { - if (obj.IsLoggingOut) - { - object sp = null; - if (obj.Scene.TryGetScenePresence(obj.AgentId, out sp)) - { - if (((ScenePresence)sp).IsChildAgent) - return; - } + if (obj.SceneAgent.IsChildAgent) + return; - // Let's find out if this is a foreign user or a local user - IUserManagement uMan = Scene.RequestModuleInterface(); -// UserAccount account = Scene.UserAccountService.GetUserAccount(Scene.RegionInfo.ScopeID, obj.AgentId); - if (uMan != null && uMan.IsLocalGridUser(obj.AgentId)) - { - // local grid user - return; - } + // Let's find out if this is a foreign user or a local user + IUserManagement uMan = Scene.RequestModuleInterface(); +// UserAccount account = Scene.UserAccountService.GetUserAccount(Scene.RegionInfo.ScopeID, obj.AgentId); - AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode); + if (uMan != null && uMan.IsLocalGridUser(obj.AgentId)) + { + // local grid user + return; + } - if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) - { - string url = aCircuit.ServiceURLs["HomeURI"].ToString(); - IUserAgentService security = new UserAgentServiceConnector(url); - security.LogoutAgent(obj.AgentId, obj.SessionId); - //m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Sent logout call to UserAgentService @ {0}", url); - } - else + AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode); + + if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) + { + string url = aCircuit.ServiceURLs["HomeURI"].ToString(); + IUserAgentService security = new UserAgentServiceConnector(url); + security.LogoutAgent(obj.AgentId, obj.SessionId); + //m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Sent logout call to UserAgentService @ {0}", url); + } + else + { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: HomeURI not found for agent {0} logout", obj.AgentId); } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs index 4cf62ec..b0edce7 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs @@ -79,29 +79,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser public void OnConnectionClose(IClientAPI client) { - if (client.IsLoggingOut) - { - object sp = null; - Vector3 position = new Vector3(128, 128, 0); - Vector3 lookat = new Vector3(0, 1, 0); - - if (client.Scene.TryGetScenePresence(client.AgentId, out sp)) - { - if (sp is ScenePresence) - { - if (((ScenePresence)sp).IsChildAgent) - return; - - position = ((ScenePresence)sp).AbsolutePosition; - lookat = ((ScenePresence)sp).Lookat; - } - } - -// m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); - m_GridUserService.LoggedOut(client.AgentId.ToString(), client.SessionId, client.Scene.RegionInfo.RegionID, position, lookat); - } + if (client.SceneAgent.IsChildAgent) + return; +// m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); + m_GridUserService.LoggedOut( + client.AgentId.ToString(), client.SessionId, client.Scene.RegionInfo.RegionID, + client.SceneAgent.AbsolutePosition, client.SceneAgent.Lookat); } - } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs index b43745c..172bea1 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs @@ -79,7 +79,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence public void OnConnectionClose(IClientAPI client) { - if (client.IsLoggingOut && !client.SceneAgent.IsChildAgent) + if (!client.SceneAgent.IsChildAgent) { // m_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); m_PresenceService.LogoutAgent(client.SessionId); diff --git a/OpenSim/Region/Framework/Scenes/AsyncInventorySender.cs b/OpenSim/Region/Framework/Scenes/AsyncInventorySender.cs index 9cb5674..d9d2e64 100644 --- a/OpenSim/Region/Framework/Scenes/AsyncInventorySender.cs +++ b/OpenSim/Region/Framework/Scenes/AsyncInventorySender.cs @@ -137,7 +137,7 @@ namespace OpenSim.Region.Framework.Scenes } } - if (fh.Client.IsLoggingOut) + if (!fh.Client.IsActive) continue; // m_log.DebugFormat( diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs index 2267325..95e4bab 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs @@ -79,27 +79,13 @@ namespace OpenSim.Services.Connectors.SimianGrid public void OnConnectionClose(IClientAPI client) { - if (client.IsLoggingOut) - { - object sp = null; - Vector3 position = new Vector3(128, 128, 0); - Vector3 lookat = new Vector3(0, 1, 0); - - if (client.Scene.TryGetScenePresence(client.AgentId, out sp)) - { - if (sp is ScenePresence) - { - if (((ScenePresence)sp).IsChildAgent) - return; - - position = ((ScenePresence)sp).AbsolutePosition; - lookat = ((ScenePresence)sp).Lookat; - } - } + if (client.SceneAgent.IsChildAgent) + return; -// m_log.DebugFormat("[SIMIAN ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); - m_GridUserService.LoggedOut(client.AgentId.ToString(), client.SessionId, client.Scene.RegionInfo.RegionID, position, lookat); - } +// m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); + m_GridUserService.LoggedOut( + client.AgentId.ToString(), client.SessionId, client.Scene.RegionInfo.RegionID, + client.SceneAgent.AbsolutePosition, client.SceneAgent.Lookat); } void OnEnteringNewParcel(ScenePresence sp, int localLandID, UUID regionID) @@ -111,4 +97,4 @@ namespace OpenSim.Services.Connectors.SimianGrid }); } } -} +} \ No newline at end of file -- cgit v1.1