From 7aa32ac6e0992249391b4d62d93c3ebb7bca82bf Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 22 Nov 2008 23:38:25 +0000 Subject: [PATCH] Add root agent tracking to presence module --- .../Avatar/InstantMessage/PresenceModule.cs | 22 ++++++++++++++----- .../Region/Environment/Scenes/EventManager.cs | 6 ++--- OpenSim/Region/Environment/Scenes/Scene.cs | 2 +- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/PresenceModule.cs index 48c77170a4..003ca8e507 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/PresenceModule.cs @@ -50,6 +50,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage private bool m_Gridmode = false; private List m_Scenes = new List(); + private Dictionary m_RootAgents = + new Dictionary(); + public event PresenceChange OnPresenceChange; public event BulkPresenceData OnBulkPresenceData; @@ -69,10 +72,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage lock (m_Scenes) { - if (m_Scenes.Count == 0) - { - } - if (m_Gridmode) NotifyMessageServerOfStartup(scene); @@ -119,10 +118,23 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage public void OnConnectionClosed(IClientAPI client) { + if (!(client.Scene is Scene)) + return; + + if (!(m_RootAgents.ContainsKey(client.AgentId))) + return; + + Scene scene = (Scene)client.Scene; + + if (m_RootAgents[client.AgentId] != scene) + return; + + m_RootAgents.Remove(client.AgentId); } - public void OnSetRootAgentScene(UUID agentID) + public void OnSetRootAgentScene(UUID agentID, Scene scene) { + m_RootAgents[agentID] = scene; } private void NotifyMessageServerOfStartup(Scene scene) diff --git a/OpenSim/Region/Environment/Scenes/EventManager.cs b/OpenSim/Region/Environment/Scenes/EventManager.cs index cdaff51866..598f8b4b88 100644 --- a/OpenSim/Region/Environment/Scenes/EventManager.cs +++ b/OpenSim/Region/Environment/Scenes/EventManager.cs @@ -98,7 +98,7 @@ namespace OpenSim.Region.Environment.Scenes public delegate void OnPermissionErrorDelegate(UUID user, string reason); - public delegate void OnSetRootAgentSceneDelegate(UUID agentID); + public delegate void OnSetRootAgentSceneDelegate(UUID agentID, Scene scene); public event OnSetRootAgentSceneDelegate OnSetRootAgentScene; @@ -919,11 +919,11 @@ namespace OpenSim.Region.Environment.Scenes handlerCollidingEnd(localId, colliders); } - public void TriggerSetRootAgentScene(UUID agentID) + public void TriggerSetRootAgentScene(UUID agentID, Scene scene) { handlerSetRootAgentScene = OnSetRootAgentScene; if (handlerSetRootAgentScene != null) - handlerSetRootAgentScene(agentID); + handlerSetRootAgentScene(agentID, scene); } } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 0c5eb62972..d2e797a571 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -4215,7 +4215,7 @@ namespace OpenSim.Region.Environment.Scenes inv.SetRootAgentScene(agentID, this); - EventManager.TriggerSetRootAgentScene(agentID); + EventManager.TriggerSetRootAgentScene(agentID, this); } public bool NeedSceneCacheClear(UUID agentID)