Add an event for an orderly region shutdown that fires once per region before

the SceneGraph is torn down.
avinationmerge
Melanie 2011-05-24 00:53:28 +02:00
parent b9fb7cdf9f
commit 8b42f824d3
2 changed files with 27 additions and 0 deletions

View File

@ -115,6 +115,10 @@ namespace OpenSim.Region.Framework.Scenes
public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
public delegate void SceneShuttingDownDelegate(Scene scene);
public event SceneShuttingDownDelegate OnSceneShuttingDown;
/// <summary>
/// Fired when an object is touched/grabbed.
/// </summary>
@ -2217,5 +2221,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);
}
}
}
}
}
}

View File

@ -1091,6 +1091,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)
{