converting Chat module and Concierge module to new style region modules
parent
1df80943b0
commit
912be7a2ac
|
@ -37,7 +37,7 @@ using OpenSim.Region.Framework.Scenes;
|
||||||
|
|
||||||
namespace OpenSim.Region.CoreModules.Avatar.Chat
|
namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||||
{
|
{
|
||||||
public class ChatModule : IRegionModule
|
public class ChatModule : ISharedRegionModule
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log =
|
private static readonly ILog m_log =
|
||||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
@ -50,27 +50,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||||
private int m_whisperdistance = 10;
|
private int m_whisperdistance = 10;
|
||||||
private List<Scene> m_scenes = new List<Scene>();
|
private List<Scene> m_scenes = new List<Scene>();
|
||||||
|
|
||||||
internal object m_syncInit = new object();
|
internal object m_syncy = new object();
|
||||||
|
|
||||||
#region IRegionModule Members
|
internal IConfig m_config;
|
||||||
public virtual void Initialise(Scene scene, IConfigSource 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_config = config.Configs["Chat"];
|
||||||
m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance);
|
|
||||||
m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance);
|
if (null == m_config)
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
{
|
||||||
|
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))
|
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_log.InfoFormat("[CHAT]: Initialized for {0} w:{1} s:{2} S:{3}", scene.RegionInfo.RegionName,
|
||||||
m_whisperdistance, m_saydistance, m_shoutdistance);
|
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 Close()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void PostInitialise()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public virtual string Name
|
public virtual string Name
|
||||||
{
|
{
|
||||||
get { return "ChatModule"; }
|
get { return "ChatModule"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool IsSharedModule
|
|
||||||
{
|
|
||||||
get { return true; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
<RegionModule id="HGAssetBroker" type="OpenSim.Region.CoreModules.ServiceConnectors.Asset.HGAssetBroker" />
|
<RegionModule id="HGAssetBroker" type="OpenSim.Region.CoreModules.ServiceConnectors.Asset.HGAssetBroker" />
|
||||||
<RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" />
|
<RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" />
|
||||||
<RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" />
|
<RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" />
|
||||||
|
<RegionModule id="Chat" type="OpenSim.Region.CoreModules.Avatar.Chat.ChatModule" />
|
||||||
</Extension>
|
</Extension>
|
||||||
|
|
||||||
<Extension path = "/OpenSim/WindModule">
|
<Extension path = "/OpenSim/WindModule">
|
||||||
|
|
|
@ -47,7 +47,7 @@ using OpenSim.Region.CoreModules.Avatar.Chat;
|
||||||
|
|
||||||
namespace OpenSim.Region.OptionalModules.Avatar.Concierge
|
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);
|
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();
|
internal object m_syncy = new object();
|
||||||
|
|
||||||
#region IRegionModule Members
|
internal bool m_enabled = false;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_config.GetBoolean("enabled", false))
|
#region ISharedRegionModule Members
|
||||||
{
|
public override void Initialise(IConfigSource config)
|
||||||
//_log.InfoFormat("[Concierge]: module disabled by OpenSim.ini configuration");
|
{
|
||||||
return;
|
m_config = config.Configs["Concierge"];
|
||||||
}
|
|
||||||
}
|
if (null == m_config)
|
||||||
catch (Exception)
|
|
||||||
{
|
{
|
||||||
m_log.Info("[Concierge]: module not configured");
|
m_log.Info("[Concierge]: no config found, plugin disabled");
|
||||||
return;
|
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,
|
// check whether ChatModule has been disabled: if yes,
|
||||||
// then we'll "stand in"
|
// then we'll "stand in"
|
||||||
try
|
try
|
||||||
|
@ -140,6 +138,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
|
||||||
m_regions = new Regex(@regions, RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
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);
|
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);
|
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()
|
public override void PostInitialise()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -181,12 +219,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
|
||||||
{
|
{
|
||||||
get { return "ConciergeModule"; }
|
get { return "ConciergeModule"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsSharedModule
|
|
||||||
{
|
|
||||||
get { return true; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ISimChat Members
|
#region ISimChat Members
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
<Extension path = "/OpenSim/RegionModules">
|
<Extension path = "/OpenSim/RegionModules">
|
||||||
<RegionModule id="IRCBridge" type="OpenSim.Region.OptionalModules.Avatar.Chat.IRCBridgeModule" />
|
<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="XmlRpcGroups" type="OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.XmlRpcGroupsModule" />
|
||||||
<RegionModule id="XmlRpcGroupsMessaging" type="OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.XmlRpcGroupsMessaging" />
|
<RegionModule id="XmlRpcGroupsMessaging" type="OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.XmlRpcGroupsMessaging" />
|
||||||
</Extension>
|
</Extension>
|
||||||
|
|
Loading…
Reference in New Issue