From 4973fddc51a4a9e3952bd2decd0ea1842b742141 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 18 Jul 2012 21:52:07 +0100
Subject: Establish EventManager.OnRegionReady event. This will only be
triggerred once when the region is ready.
Switch MapImageServiceModule to use this.
---
.../MapImage/MapImageServiceModule.cs | 10 ++----
OpenSim/Region/Framework/Scenes/EventManager.cs | 37 ++++++++++++++++++++--
OpenSim/Region/Framework/Scenes/Scene.cs | 1 +
.../RegionReadyModule/RegionReadyModule.cs | 2 ++
4 files changed, 39 insertions(+), 11 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
index 9033460..5641804 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
@@ -146,10 +146,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
lock (m_scenes)
m_scenes[scene.RegionInfo.RegionID] = scene;
- scene.EventManager.OnLoginsEnabled += OnLoginsEnabled;
+ scene.EventManager.OnRegionReady += s => UploadMapTile(s);
}
-
///
///
///
@@ -163,12 +162,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
}
#endregion ISharedRegionModule
-
- void OnLoginsEnabled(IScene scene)
- {
- UploadMapTile(scene);
- }
-
+
///
///
///
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index e2380b7..714d70d 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -505,6 +505,16 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void LoginsEnabled(IScene scene);
public event LoginsEnabled OnLoginsEnabled;
+ ///
+ /// Fired when a region is considered ready for use.
+ ///
+ ///
+ /// A region is considered ready when startup operations such as loading of scripts already on the region
+ /// have been completed.
+ ///
+ public delegate void RegionReady(IScene scene);
+ public event RegionReady OnRegionReady;
+
public delegate void PrimsLoaded(Scene s);
public event PrimsLoaded OnPrimsLoaded;
@@ -2476,11 +2486,11 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- public void TriggerLoginsEnabled(Scene scene)
+ public void TriggerLoginsEnabled(IScene scene)
{
LoginsEnabled handler = OnLoginsEnabled;
- if ( handler != null)
+ if (handler != null)
{
foreach (LoginsEnabled d in handler.GetInvocationList())
{
@@ -2490,7 +2500,28 @@ namespace OpenSim.Region.Framework.Scenes
}
catch (Exception e)
{
- m_log.ErrorFormat("[EVENT MANAGER]: Delegate for LoginsEnabled failed - continuing {0} - {1}",
+ m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnLoginsEnabled failed - continuing {0} - {1}",
+ e.Message, e.StackTrace);
+ }
+ }
+ }
+ }
+
+ public void TriggerRegionReady(IScene scene)
+ {
+ RegionReady handler = OnRegionReady;
+
+ if (handler != null)
+ {
+ foreach (RegionReady d in handler.GetInvocationList())
+ {
+ try
+ {
+ d(scene);
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionReady 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 8a28ee4..12cc0d3 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1501,6 +1501,7 @@ namespace OpenSim.Region.Framework.Scenes
{
m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
LoginsDisabled = false;
+ EventManager.TriggerRegionReady(this);
}
m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface(), RegionInfo);
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
index 29515de..e09e633 100644
--- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
@@ -238,6 +238,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
{
RRAlert("enabled");
}
+
+ m_scene.EventManager.TriggerRegionReady(m_scene);
}
m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue;
--
cgit v1.1