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 OnLoginsEnabledStatusChange0.7.3-extended
parent
2d66fcd4cd
commit
9d6ea27df0
|
@ -71,6 +71,14 @@ namespace OpenSim.Framework
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool LoginsEnabled { get; set; }
|
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; }
|
float TimeDilation { get; }
|
||||||
|
|
||||||
bool AllowScriptCrossings { get; }
|
bool AllowScriptCrossings { get; }
|
||||||
|
|
|
@ -128,11 +128,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
|
||||||
m_enabled = true;
|
m_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
|
||||||
///
|
|
||||||
///</summary>
|
|
||||||
|
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
///
|
///
|
||||||
///</summary>
|
///</summary>
|
||||||
|
@ -146,7 +141,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
|
||||||
lock (m_scenes)
|
lock (m_scenes)
|
||||||
m_scenes[scene.RegionInfo.RegionID] = scene;
|
m_scenes[scene.RegionInfo.RegionID] = scene;
|
||||||
|
|
||||||
scene.EventManager.OnRegionReady += s => UploadMapTile(s);
|
scene.EventManager.OnRegionReadyStatusChange += s => { if (s.Ready) UploadMapTile(s); };
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
|
|
|
@ -506,8 +506,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// A region is considered ready when startup operations such as loading of scripts already on the region
|
/// A region is considered ready when startup operations such as loading of scripts already on the region
|
||||||
/// have been completed.
|
/// have been completed.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public event RegionReady OnRegionReady;
|
public event Action<IScene> OnRegionReadyStatusChange;
|
||||||
public delegate void RegionReady(IScene scene);
|
|
||||||
|
|
||||||
public delegate void PrimsLoaded(Scene s);
|
public delegate void PrimsLoaded(Scene s);
|
||||||
public event PrimsLoaded OnPrimsLoaded;
|
public event PrimsLoaded OnPrimsLoaded;
|
||||||
|
@ -2459,13 +2458,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)
|
if (handler != null)
|
||||||
{
|
{
|
||||||
foreach (RegionReady d in handler.GetInvocationList())
|
foreach (Action<IScene> d in handler.GetInvocationList())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -2473,7 +2472,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
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);
|
e.Message, e.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1457,8 +1457,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_sceneGridService.InformNeighborsThatRegionisUp(
|
m_sceneGridService.InformNeighborsThatRegionisUp(
|
||||||
RequestModuleInterface<INeighbourService>(), RegionInfo);
|
RequestModuleInterface<INeighbourService>(), RegionInfo);
|
||||||
|
|
||||||
// Region ready should always be triggered whether logins are immediately enabled or not.
|
// Region ready should always be set
|
||||||
EventManager.TriggerRegionReady(this);
|
Ready = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -124,6 +124,24 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
private bool m_loginsEnabled;
|
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
|
public float TimeDilation
|
||||||
{
|
{
|
||||||
get { return 1.0f; }
|
get { return 1.0f; }
|
||||||
|
|
|
@ -47,6 +47,48 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
public event RestartSim OnRestartSim;
|
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;
|
private static SceneManager m_instance = null;
|
||||||
public static SceneManager Instance
|
public static SceneManager Instance
|
||||||
{
|
{
|
||||||
|
@ -141,10 +183,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
public void Add(Scene scene)
|
public void Add(Scene scene)
|
||||||
{
|
{
|
||||||
scene.OnRestart += HandleRestart;
|
|
||||||
|
|
||||||
lock (m_localScenes)
|
lock (m_localScenes)
|
||||||
m_localScenes.Add(scene);
|
m_localScenes.Add(scene);
|
||||||
|
|
||||||
|
scene.OnRestart += HandleRestart;
|
||||||
|
scene.EventManager.OnRegionReadyStatusChange += HandleRegionReadyStatusChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleRestart(RegionInfo rdata)
|
public void HandleRestart(RegionInfo rdata)
|
||||||
|
@ -175,6 +218,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
OnRestartSim(rdata);
|
OnRestartSim(rdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleRegionReadyStatusChange(IScene scene)
|
||||||
|
{
|
||||||
|
lock (m_localScenes)
|
||||||
|
AllRegionsReady = m_localScenes.TrueForAll(s => s.Ready);
|
||||||
|
}
|
||||||
|
|
||||||
public void SendSimOnlineNotification(ulong regionHandle)
|
public void SendSimOnlineNotification(ulong regionHandle)
|
||||||
{
|
{
|
||||||
RegionInfo Result = null;
|
RegionInfo Result = null;
|
||||||
|
|
|
@ -232,7 +232,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
|
||||||
RRAlert("enabled");
|
RRAlert("enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_scene.EventManager.TriggerRegionReady(m_scene);
|
m_scene.Ready = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OarLoadingAlert(string msg)
|
public void OarLoadingAlert(string msg)
|
||||||
|
|
|
@ -644,7 +644,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
|
|
||||||
// If region ready has been triggered, then the region had no scripts to compile and completed its other
|
// If region ready has been triggered, then the region had no scripts to compile and completed its other
|
||||||
// work.
|
// work.
|
||||||
m_Scene.EventManager.OnRegionReady += s => m_InitialStartup = false;
|
m_Scene.EventManager.OnRegionReadyStatusChange += s => { if (s.Ready) m_InitialStartup = false; };
|
||||||
|
|
||||||
if (m_SleepTime > 0)
|
if (m_SleepTime > 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue