Establish EventManager.OnRegionReady event. This will only be triggerred once when the region is ready.

Switch MapImageServiceModule to use this.
0.7.3-extended
Justin Clark-Casey (justincc) 2012-07-18 21:52:07 +01:00
parent c8f60acc30
commit 4debc67b48
4 changed files with 39 additions and 10 deletions

View File

@ -146,7 +146,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.OnLoginsEnabled += OnLoginsEnabled; scene.EventManager.OnRegionReady += s => UploadMapTile(s);
} }
///<summary> ///<summary>
@ -163,11 +163,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
#endregion ISharedRegionModule #endregion ISharedRegionModule
void OnLoginsEnabled(IScene scene)
{
UploadMapTile(scene);
}
///<summary> ///<summary>
/// ///
///</summary> ///</summary>

View File

@ -498,6 +498,16 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void LoginsEnabled(IScene scene); public delegate void LoginsEnabled(IScene scene);
public event LoginsEnabled OnLoginsEnabled; public event LoginsEnabled OnLoginsEnabled;
/// <summary>
/// Fired when a region is considered ready for use.
/// </summary>
/// <remarks>
/// A region is considered ready when startup operations such as loading of scripts already on the region
/// have been completed.
/// </remarks>
public delegate void RegionReady(IScene scene);
public event RegionReady OnRegionReady;
public delegate void PrimsLoaded(Scene s); public delegate void PrimsLoaded(Scene s);
public event PrimsLoaded OnPrimsLoaded; public event PrimsLoaded OnPrimsLoaded;
@ -2427,11 +2437,11 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
public void TriggerLoginsEnabled(Scene scene) public void TriggerLoginsEnabled(IScene scene)
{ {
LoginsEnabled handler = OnLoginsEnabled; LoginsEnabled handler = OnLoginsEnabled;
if ( handler != null) if (handler != null)
{ {
foreach (LoginsEnabled d in handler.GetInvocationList()) foreach (LoginsEnabled d in handler.GetInvocationList())
{ {
@ -2441,7 +2451,28 @@ namespace OpenSim.Region.Framework.Scenes
} }
catch (Exception e) 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); e.Message, e.StackTrace);
} }
} }

View File

@ -1459,6 +1459,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
LoginsDisabled = false; LoginsDisabled = false;
EventManager.TriggerRegionReady(this);
} }
m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);

View File

@ -244,6 +244,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
{ {
RRAlert("enabled"); RRAlert("enabled");
} }
m_scene.EventManager.TriggerRegionReady(m_scene);
} }
m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue;