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

the SceneGraph is torn down.
bulletsim
Melanie 2011-05-24 00:53:28 +02:00
parent 24c00acedc
commit 178d541dca
2 changed files with 27 additions and 0 deletions

View File

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

View File

@ -1064,6 +1064,8 @@ namespace OpenSim.Region.Framework.Scenes
shuttingdown = true; shuttingdown = true;
m_log.Debug("[SCENE]: Persisting changed objects"); m_log.Debug("[SCENE]: Persisting changed objects");
EventManager.TriggerSceneShuttingDown(this);
EntityBase[] entities = GetEntities(); EntityBase[] entities = GetEntities();
foreach (EntityBase entity in entities) foreach (EntityBase entity in entities)
{ {