converting Chat module and Concierge module to new style region modules

0.6.6-post-fixes
Dr Scofield 2009-05-22 14:25:50 +00:00
parent 1df80943b0
commit 912be7a2ac
4 changed files with 109 additions and 48 deletions

View File

@ -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<Scene> m_scenes = new List<Scene>();
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_config = config.Configs["Chat"];
if (null == m_config)
{
m_enabled = config.Configs["Chat"].GetBoolean("enabled", m_enabled);
if (!m_enabled) return;
m_log.Info("[CHAT]: no config found, plugin disabled");
return;
}
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);
}
catch (Exception)
{
}
lock (m_syncInit)
public virtual void AddRegion(Scene scene)
{
if (!m_enabled) return;
lock (m_syncy)
{
if (!m_scenes.Contains(scene))
{
@ -85,24 +97,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
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

View File

@ -18,6 +18,7 @@
<RegionModule id="HGAssetBroker" type="OpenSim.Region.CoreModules.ServiceConnectors.Asset.HGAssetBroker" />
<RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" />
<RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" />
<RegionModule id="Chat" type="OpenSim.Region.CoreModules.Avatar.Chat.ChatModule" />
</Extension>
<Extension path = "/OpenSim/WindModule">

View File

@ -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
m_config = config.Configs["Concierge"];
if (null == m_config)
{
if ((m_config = config.Configs["Concierge"]) == null)
{
//_log.InfoFormat("[Concierge]: no configuration section [Concierge] in OpenSim.ini: module not configured");
m_log.Info("[Concierge]: no config found, plugin disabled");
return;
}
if (!m_config.GetBoolean("enabled", false))
{
//_log.InfoFormat("[Concierge]: module disabled by OpenSim.ini configuration");
return;
}
}
catch (Exception)
{
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

View File

@ -9,6 +9,7 @@
<Extension path = "/OpenSim/RegionModules">
<RegionModule id="IRCBridge" type="OpenSim.Region.OptionalModules.Avatar.Chat.IRCBridgeModule" />
<RegionModule id="Concierge" type="OpenSim.Region.OptionalModules.Avatar.Concierge.ConciergeModule" />
<RegionModule id="XmlRpcGroups" type="OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.XmlRpcGroupsModule" />
<RegionModule id="XmlRpcGroupsMessaging" type="OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.XmlRpcGroupsMessaging" />
</Extension>