diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 337644d81a..47c9db5246 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs @@ -37,7 +37,7 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.Avatar.Chat { - public class ChatModule : IRegionModule + public class ChatModule : ISharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -50,27 +50,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat private int m_whisperdistance = 10; private List m_scenes = new List(); - internal object m_syncInit = new object(); + internal object m_syncy = new object(); - #region IRegionModule Members - public virtual void Initialise(Scene scene, IConfigSource config) + internal IConfig m_config; + + #region ISharedRegionModule Members + public virtual void Initialise(IConfigSource config) { - // wrap this in a try block so that defaults will work if - // the config file doesn't specify otherwise. - try - { - m_enabled = config.Configs["Chat"].GetBoolean("enabled", m_enabled); - if (!m_enabled) return; - m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); - m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); - m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); - } - catch (Exception) + m_config = config.Configs["Chat"]; + + if (null == m_config) { + m_log.Info("[CHAT]: no config found, plugin disabled"); + return; } - lock (m_syncInit) + if (!m_config.GetBoolean("enabled", false)) + { + m_log.Info("[CHAT]: plugin disabled by configuration"); + return; + } + m_enabled = true; + + m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); + m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); + m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); + } + + public virtual void AddRegion(Scene scene) + { + if (!m_enabled) return; + + lock (m_syncy) { if (!m_scenes.Contains(scene)) { @@ -84,25 +96,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat m_log.InfoFormat("[CHAT]: Initialized for {0} w:{1} s:{2} S:{3}", scene.RegionInfo.RegionName, m_whisperdistance, m_saydistance, m_shoutdistance); } - - public virtual void PostInitialise() + + public virtual void RegionLoaded(Scene scene) { } + public virtual void RemoveRegion(Scene scene) + { + if (!m_enabled) return; + + lock (m_syncy) + { + if (m_scenes.Contains(scene)) + { + scene.EventManager.OnNewClient -= OnNewClient; + scene.EventManager.OnChatFromWorld -= OnChatFromWorld; + scene.EventManager.OnChatBroadcast -= OnChatBroadcast; + m_scenes.Remove(scene); + } + } + } + public virtual void Close() { } + public virtual void PostInitialise() + { + } + public virtual string Name { get { return "ChatModule"; } } - public virtual bool IsSharedModule - { - get { return true; } - } - #endregion diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 3b6c1dc31b..6c80598e20 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -18,6 +18,7 @@ + diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs index 604b21d186..687b2daa49 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs @@ -47,7 +47,7 @@ using OpenSim.Region.CoreModules.Avatar.Chat; namespace OpenSim.Region.OptionalModules.Avatar.Concierge { - public class ConciergeModule : ChatModule, IRegionModule + public class ConciergeModule : ChatModule, ISharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -76,29 +76,27 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge internal object m_syncy = new object(); - #region IRegionModule Members - public override void Initialise(Scene scene, IConfigSource config) - { - try - { - if ((m_config = config.Configs["Concierge"]) == null) - { - //_log.InfoFormat("[Concierge]: no configuration section [Concierge] in OpenSim.ini: module not configured"); - return; - } + internal bool m_enabled = false; - if (!m_config.GetBoolean("enabled", false)) - { - //_log.InfoFormat("[Concierge]: module disabled by OpenSim.ini configuration"); - return; - } - } - catch (Exception) + #region ISharedRegionModule Members + public override void Initialise(IConfigSource config) + { + m_config = config.Configs["Concierge"]; + + if (null == m_config) { - m_log.Info("[Concierge]: module not configured"); + m_log.Info("[Concierge]: no config found, plugin disabled"); return; } + if (!m_config.GetBoolean("enabled", false)) + { + m_log.Info("[Concierge]: plugin disabled by configuration"); + return; + } + m_enabled = true; + + // check whether ChatModule has been disabled: if yes, // then we'll "stand in" try @@ -140,6 +138,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge m_regions = new Regex(@regions, RegexOptions.Compiled | RegexOptions.IgnoreCase); } } + } + + + public override void AddRegion(Scene scene) + { + if (!m_enabled) return; scene.CommsManager.HttpServer.AddXmlRPCHandler("concierge_update_welcome", XmlRpcUpdateWelcomeMethod, false); @@ -169,6 +173,40 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge m_log.InfoFormat("[Concierge]: initialized for {0}", scene.RegionInfo.RegionName); } + public override void RemoveRegion(Scene scene) + { + if (!m_enabled) return; + + scene.CommsManager.HttpServer.RemoveXmlRPCHandler("concierge_update_welcome"); + + lock (m_syncy) + { + // unsubscribe from NewClient events + scene.EventManager.OnNewClient -= OnNewClient; + + // unsubscribe from *Chat events + scene.EventManager.OnChatFromWorld -= OnChatFromWorld; + if (!m_replacingChatModule) + scene.EventManager.OnChatFromClient -= OnChatFromClient; + scene.EventManager.OnChatBroadcast -= OnChatBroadcast; + + // unsubscribe from agent change events + scene.EventManager.OnMakeRootAgent -= OnMakeRootAgent; + scene.EventManager.OnMakeChildAgent -= OnMakeChildAgent; + + if (m_scenes.Contains(scene)) + { + m_scenes.Remove(scene); + } + + if (m_conciergedScenes.Contains(scene)) + { + m_conciergedScenes.Remove(scene); + } + } + m_log.InfoFormat("[Concierge]: removed {0}", scene.RegionInfo.RegionName); + } + public override void PostInitialise() { } @@ -181,12 +219,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge { get { return "ConciergeModule"; } } - - public override bool IsSharedModule - { - get { return true; } - } - #endregion #region ISimChat Members diff --git a/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml b/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml index 69d3e573ee..01a5d8b5d5 100644 --- a/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml +++ b/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml @@ -9,6 +9,7 @@ +