From 31304c222df1e5a832afd0ebcf7d3ed403543e54 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 25 Jul 2012 21:00:59 +0100
Subject: Make SceneManager.OnRegionsReadyStatusChange event available.
This is fired when all regions are ready or when at least one region becomes not ready.
Recently added EventManager.OnRegionReady becomes OnRegionReadyStatusChange to match OnLoginsEnabledStatusChange
---
.../MapImage/MapImageServiceModule.cs | 7 +--
OpenSim/Region/Framework/Scenes/EventManager.cs | 11 ++---
OpenSim/Region/Framework/Scenes/Scene.cs | 4 +-
OpenSim/Region/Framework/Scenes/SceneBase.cs | 18 ++++++++
OpenSim/Region/Framework/Scenes/SceneManager.cs | 53 +++++++++++++++++++++-
.../RegionReadyModule/RegionReadyModule.cs | 2 +-
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 2 +-
7 files changed, 79 insertions(+), 18 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
index 5641804..9d282b8 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
@@ -131,11 +131,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
///
///
///
-
-
- ///
- ///
- ///
public void AddRegion(Scene scene)
{
if (! m_enabled)
@@ -146,7 +141,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
lock (m_scenes)
m_scenes[scene.RegionInfo.RegionID] = scene;
- scene.EventManager.OnRegionReady += s => UploadMapTile(s);
+ scene.EventManager.OnRegionReadyStatusChange += s => { if (s.Ready) UploadMapTile(s); };
}
///
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 620b605..6dea2f0 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -513,8 +513,7 @@ namespace OpenSim.Region.Framework.Scenes
/// A region is considered ready when startup operations such as loading of scripts already on the region
/// have been completed.
///
- public event RegionReady OnRegionReady;
- public delegate void RegionReady(IScene scene);
+ public event Action OnRegionReadyStatusChange;
public delegate void PrimsLoaded(Scene s);
public event PrimsLoaded OnPrimsLoaded;
@@ -2508,13 +2507,13 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- public void TriggerRegionReady(IScene scene)
+ public void TriggerRegionReadyStatusChange(IScene scene)
{
- RegionReady handler = OnRegionReady;
+ Action handler = OnRegionReadyStatusChange;
if (handler != null)
{
- foreach (RegionReady d in handler.GetInvocationList())
+ foreach (Action d in handler.GetInvocationList())
{
try
{
@@ -2522,7 +2521,7 @@ namespace OpenSim.Region.Framework.Scenes
}
catch (Exception e)
{
- m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionReady failed - continuing {0} - {1}",
+ m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionReadyStatusChange 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 ee34338..20918bd 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1499,8 +1499,8 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGridService.InformNeighborsThatRegionisUp(
RequestModuleInterface(), RegionInfo);
- // Region ready should always be triggered whether logins are immediately enabled or not.
- EventManager.TriggerRegionReady(this);
+ // Region ready should always be set
+ Ready = true;
}
else
{
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 282fc5e..b87a38a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -124,6 +124,24 @@ namespace OpenSim.Region.Framework.Scenes
}
private bool m_loginsEnabled;
+ public bool Ready
+ {
+ get
+ {
+ return m_ready;
+ }
+
+ set
+ {
+ if (m_ready != value)
+ {
+ m_ready = value;
+ EventManager.TriggerRegionReadyStatusChange(this);
+ }
+ }
+ }
+ private bool m_ready;
+
public float TimeDilation
{
get { return 1.0f; }
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index d73a959..c81b55d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -47,6 +47,48 @@ namespace OpenSim.Region.Framework.Scenes
public event RestartSim OnRestartSim;
+ ///
+ /// Fired when either all regions are ready for use or at least one region has become unready for use where
+ /// previously all regions were ready.
+ ///
+ public event Action OnRegionsReadyStatusChange;
+
+ ///
+ /// Are all regions ready for use?
+ ///
+ public bool AllRegionsReady
+ {
+ get
+ {
+ return m_allRegionsReady;
+ }
+
+ private set
+ {
+ if (m_allRegionsReady != value)
+ {
+ m_allRegionsReady = value;
+ Action handler = OnRegionsReadyStatusChange;
+ if (handler != null)
+ {
+ foreach (Action d in handler.GetInvocationList())
+ {
+ try
+ {
+ d(this);
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat("[SCENE MANAGER]: Delegate for OnRegionsReadyStatusChange failed - continuing {0} - {1}",
+ e.Message, e.StackTrace);
+ }
+ }
+ }
+ }
+ }
+ }
+ private bool m_allRegionsReady;
+
private static SceneManager m_instance = null;
public static SceneManager Instance
{
@@ -141,10 +183,11 @@ namespace OpenSim.Region.Framework.Scenes
public void Add(Scene scene)
{
- scene.OnRestart += HandleRestart;
-
lock (m_localScenes)
m_localScenes.Add(scene);
+
+ scene.OnRestart += HandleRestart;
+ scene.EventManager.OnRegionReadyStatusChange += HandleRegionReadyStatusChange;
}
public void HandleRestart(RegionInfo rdata)
@@ -175,6 +218,12 @@ namespace OpenSim.Region.Framework.Scenes
OnRestartSim(rdata);
}
+ private void HandleRegionReadyStatusChange(IScene scene)
+ {
+ lock (m_localScenes)
+ AllRegionsReady = m_localScenes.TrueForAll(s => s.Ready);
+ }
+
public void SendSimOnlineNotification(ulong regionHandle)
{
RegionInfo Result = null;
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
index f459b8c..fff3a32 100644
--- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
@@ -225,7 +225,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
RRAlert("enabled");
}
- m_scene.EventManager.TriggerRegionReady(m_scene);
+ m_scene.Ready = true;
}
public void OarLoadingAlert(string msg)
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index da344d6..2dba029 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -646,7 +646,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
// If region ready has been triggered, then the region had no scripts to compile and completed its other
// work.
- m_Scene.EventManager.OnRegionReady += s => m_InitialStartup = false;
+ m_Scene.EventManager.OnRegionReadyStatusChange += s => { if (s.Ready) m_InitialStartup = false; };
if (m_SleepTime > 0)
{
--
cgit v1.1