diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 1652b82542..6db3367673 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -411,6 +411,12 @@ namespace OpenSim scene.StartTimer(); + //SYMMETRIC SYNC + //For INonSharedRegionModule, there is no more PostInitialise(). So we trigger OnPostSceneCreation event here + //to let the Sync modules to do their work once all modules are loaded and scene has interfaces to all of them. + scene.EventManager.TriggerOnPostSceneCreation(scene); + //end of SYMMETRIC SYNC + return clientServer; } diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 9b44ee37f1..f1d28665b3 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -70,23 +70,30 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Called after Initialise() public void AddRegion(Scene scene) { + m_log.Warn(LogHeader + " AddRegion() called"); + if (!m_active) return; //connect with scene m_scene = scene; - //register the module + //register the module m_scene.RegisterModuleInterface(this); // Setup the command line interface m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; InstallInterfaces(); + + //Register for the OnPostSceneCreation event + m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation; } //Called after AddRegion() has been called for all region modules of the scene public void RegionLoaded(Scene scene) { + m_log.Warn(LogHeader + " RegionLoaded() called"); + //If this one is configured to start a listener so that other actors can connect to form a overlay, start the listener. //For now, we use start topology, and ScenePersistence actor is always the one to start the listener. if (m_isSyncListenerLocal) @@ -265,6 +272,20 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_log.Warn("[REGION SYNC MODULE]: StatsTimerElapsed -- NOT yet implemented."); } + public void OnPostSceneCreation(Scene createdScene) + { + //If this is the local scene the actor is working on, find out the actor type. + if (createdScene.RegionInfo.RegionName == m_scene.RegionInfo.RegionName) + { + if(m_scene.ActorSyncModule == null){ + m_log.Error(LogHeader + "interface Scene.ActorSyncModule has not been set yet"); + return; + } + m_actorType = m_scene.ActorSyncModule.ActorType; + m_log.Warn(LogHeader + " informed about ActorType: "+m_actorType); + } + } + private void StartLocalSyncListener() { RegionSyncListenerInfo localSyncListenerInfo = GetLocalSyncListenerInfo(); @@ -583,11 +604,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private RegionSyncListenerInfo m_listenerInfo; private RegionSyncModule m_regionSyncModule; private ILog m_log; + private string LogHeader = "[RegionSyncListener]"; // The listener and the thread which listens for sync connection requests private TcpListener m_listener; private Thread m_listenerThread; - + private bool m_isListening = false; public bool IsListening { @@ -607,7 +629,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { m_listenerThread = new Thread(new ThreadStart(Listen)); m_listenerThread.Name = "RegionSyncListener"; - m_log.WarnFormat("[REGION SYNC LISTENER] Starting {0} thread", m_listenerThread.Name); + m_log.WarnFormat(LogHeader+" Starting {0} thread", m_listenerThread.Name); m_listenerThread.Start(); m_isListening = true; //m_log.Warn("[REGION SYNC SERVER] Started"); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScenePersistenceSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScenePersistenceSyncModule.cs index f91fb20fbc..6e07bc1cab 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScenePersistenceSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScenePersistenceSyncModule.cs @@ -16,28 +16,11 @@ using log4net; using System.Net; using System.Net.Sockets; using System.Threading; +using Mono.Addins; namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { - /* - public class DSGActorBase - { - protected RegionSyncModule m_regionSyncModule; - - public DSGActorBase(RegionSyncModule regionSyncModule) - { - m_regionSyncModule = regionSyncModule; - } - - public virtual void init() - { - - } - - - } - * */ - + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AttachmentsModule")] public class ScenePersistenceSyncModule : INonSharedRegionModule, IDSGActorSyncModule { #region INonSharedRegionModule @@ -66,6 +49,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule return; } + m_active = true; + + m_log.Warn(LogHeader+" Initialised"); + } //Called after Initialise() @@ -73,7 +60,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { if (!m_active) return; - + m_log.Warn(LogHeader + " AddRegion() called"); //connect with scene m_scene = scene; @@ -83,19 +70,19 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule // Setup the command line interface //m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; //InstallInterfaces(); + + //Register for the OnPostSceneCreation event + //m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation; } - //Called after AddRegion() has been called for all region modules of the scene + //Called after AddRegion() has been called for all region modules of the scene. + //NOTE::However, at this point, Scene may not have requested all the needed region module interfaces yet. public void RegionLoaded(Scene scene) { - if (m_scene.RegionSyncModule != null) - { - m_scene.RegionSyncModule.DSGActorType = m_actorType; - } - else - { - m_log.Warn("RegionSyncModule is not initiated!!"); - } + if (!m_active) + return; + m_log.Warn(LogHeader + " RegionLoaded() called"); + } public void RemoveRegion(Scene scene) @@ -141,7 +128,15 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private Scene m_scene; + private string LogHeader = "[ScenePersistenceSyncModule]"; + public void OnPostSceneCreation(Scene createdScene) + { + //If this is the local scene the actor is working on, do something + if (createdScene == m_scene) + { + } + } #endregion //ScenePersistenceSyncModule } diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index a6ae574781..a755d0347d 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -376,7 +376,6 @@ namespace OpenSim.Region.Framework.Scenes public delegate void RegionUp(GridRegion region); public event RegionUp OnRegionUp; - public class MoneyTransferArgs : EventArgs { public UUID sender; @@ -2243,5 +2242,32 @@ namespace OpenSim.Region.Framework.Scenes } } #endregion + + //SYMMETRIC SYNC + public event PostSceneCreation OnPostSceneCreation; + public delegate void PostSceneCreation(Scene createdScene); + + public void TriggerOnPostSceneCreation(Scene createdScene) + { + PostSceneCreation handler = OnPostSceneCreation; + if (handler != null) + { + foreach (PostSceneCreation d in handler.GetInvocationList()) + { + try + { + m_log.Warn("TriggerOnPostSceneCreation"); + d(createdScene); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TriggerOnPostSceneCreation failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } + } + //end of SYMMETRIC SYNC } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index bc5565a0d4..fcc7ab09aa 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -588,8 +588,16 @@ namespace OpenSim.Region.Framework.Scenes public IRegionSyncModule RegionSyncModule { get { return m_regionSyncModule; } - set { m_regionSyncModule = value; } + //set { m_regionSyncModule = value; } } + + private IDSGActorSyncModule m_DSGActorSyncModule = null; + public IDSGActorSyncModule ActorSyncModule + { + get { return m_DSGActorSyncModule; } + + } + #endregion //SYMMETRIC SYNC public ICapabilitiesModule CapsModule @@ -1281,6 +1289,25 @@ namespace OpenSim.Region.Framework.Scenes RegionSyncClientModule = RequestModuleInterface(); ScriptEngineToSceneConnectorModule = RequestModuleInterface(); + ////////////////////////////////////////////////////////////////////// + //SYMMETRIC SYNC (KittyL: started 12/23/2010) + ////////////////////////////////////////////////////////////////////// + m_regionSyncModule = RequestModuleInterface(); + if (m_regionSyncModule == null) + { + m_log.Warn("Does not find a RegionSyncModule interface"); + } + else + { + m_log.Warn("SetModuleInterfaces: RegionSyncModule interface set."); + } + + m_DSGActorSyncModule = RequestModuleInterface(); + + ////////////////////////////////////////////////////////////////////// + //end of SYMMETRIC SYNC + ////////////////////////////////////////////////////////////////////// + // Shoving this in here for now, because we have the needed // interfaces at this point //