From 912be7a2acee6f49eeee2f06879d9fff7ca183ab Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 22 May 2009 14:25:50 +0000 Subject: converting Chat module and Concierge module to new style region modules --- .../Avatar/Concierge/ConciergeModule.cs | 78 +++++++++++++++------- 1 file changed, 55 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar') diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs index 604b21d..687b2da 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,28 +76,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge internal object m_syncy = new object(); - #region IRegionModule Members - public override void Initialise(Scene scene, IConfigSource config) + internal bool m_enabled = false; + + #region ISharedRegionModule Members + public override void Initialise(IConfigSource config) { - try - { - if ((m_config = config.Configs["Concierge"]) == null) - { - //_log.InfoFormat("[Concierge]: no configuration section [Concierge] in OpenSim.ini: module not configured"); - return; - } + m_config = config.Configs["Concierge"]; - if (!m_config.GetBoolean("enabled", false)) - { - //_log.InfoFormat("[Concierge]: module disabled by OpenSim.ini configuration"); - return; - } + if (null == m_config) + { + m_log.Info("[Concierge]: no config found, plugin disabled"); + return; } - catch (Exception) + + if (!m_config.GetBoolean("enabled", false)) { - m_log.Info("[Concierge]: module not configured"); + 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" @@ -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 -- cgit v1.1