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.
---
 OpenSim/Region/Framework/Scenes/EventManager.cs | 37 +++++++++++++++++++++++--
 OpenSim/Region/Framework/Scenes/Scene.cs        |  1 +
 2 files changed, 35 insertions(+), 3 deletions(-)

(limited to 'OpenSim/Region/Framework')

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;
 
+        /// <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 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<INeighbourService>(), RegionInfo);
-- 
cgit v1.1