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
0.7.4.1
Justin Clark-Casey (justincc) 2012-07-25 21:00:59 +01:00
parent 3cf8edfd68
commit 31304c222d
8 changed files with 87 additions and 18 deletions

View File

@ -71,6 +71,14 @@ namespace OpenSim.Framework
/// </summary>
bool LoginsEnabled { get; set; }
/// <summary>
/// Is this region ready for use?
/// </summary>
/// <remarks>
/// This does not mean that logins are enabled, merely that they can be.
/// </remarks>
bool Ready { get; set; }
float TimeDilation { get; }
bool AllowScriptCrossings { get; }

View File

@ -128,11 +128,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
m_enabled = true;
}
///<summary>
///
///</summary>
///<summary>
///
///</summary>
@ -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); };
}
///<summary>

View File

@ -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.
/// </remarks>
public event RegionReady OnRegionReady;
public delegate void RegionReady(IScene scene);
public event Action<IScene> 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<IScene> handler = OnRegionReadyStatusChange;
if (handler != null)
{
foreach (RegionReady d in handler.GetInvocationList())
foreach (Action<IScene> 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);
}
}

View File

@ -1499,8 +1499,8 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGridService.InformNeighborsThatRegionisUp(
RequestModuleInterface<INeighbourService>(), 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
{

View File

@ -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; }

View File

@ -47,6 +47,48 @@ namespace OpenSim.Region.Framework.Scenes
public event RestartSim OnRestartSim;
/// <summary>
/// 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.
/// </summary>
public event Action<SceneManager> OnRegionsReadyStatusChange;
/// <summary>
/// Are all regions ready for use?
/// </summary>
public bool AllRegionsReady
{
get
{
return m_allRegionsReady;
}
private set
{
if (m_allRegionsReady != value)
{
m_allRegionsReady = value;
Action<SceneManager> handler = OnRegionsReadyStatusChange;
if (handler != null)
{
foreach (Action<SceneManager> 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;

View File

@ -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)

View File

@ -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)
{