From 178d541dcaa2d8258e3820b39818d8fd69def72e Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 May 2011 00:53:28 +0200 Subject: Add an event for an orderly region shutdown that fires once per region before the SceneGraph is torn down. --- OpenSim/Region/Framework/Scenes/EventManager.cs | 25 +++++++++++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 2 ++ 2 files changed, 27 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index fd62535..e04317b 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -111,6 +111,10 @@ namespace OpenSim.Region.Framework.Scenes public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; + public delegate void SceneShuttingDownDelegate(Scene scene); + + public event SceneShuttingDownDelegate OnSceneShuttingDown; + /// /// Fired when an object is touched/grabbed. /// @@ -2193,5 +2197,26 @@ namespace OpenSim.Region.Framework.Scenes } } } + + public void TriggerSceneShuttingDown(Scene s) + { + SceneShuttingDownDelegate handler = OnSceneShuttingDown; + if (handler != null) + { + foreach (SceneShuttingDownDelegate d in handler.GetInvocationList()) + { + try + { + d(s); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TriggerSceneShuttingDown failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } + } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index b9690fe..eabc9a6 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1064,6 +1064,8 @@ namespace OpenSim.Region.Framework.Scenes shuttingdown = true; m_log.Debug("[SCENE]: Persisting changed objects"); + EventManager.TriggerSceneShuttingDown(this); + EntityBase[] entities = GetEntities(); foreach (EntityBase entity in entities) { -- cgit v1.1