One more module converted: WebStatsModule.

integration
Diva Canto 2012-11-11 17:02:22 -08:00
parent 64fad2f80e
commit 113a9704f2
1 changed files with 93 additions and 76 deletions

View File

@ -43,15 +43,20 @@ using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using Mono.Data.SqliteClient; using Mono.Data.SqliteClient;
using Mono.Addins;
using Caps = OpenSim.Framework.Capabilities.Caps; using Caps = OpenSim.Framework.Capabilities.Caps;
using OSD = OpenMetaverse.StructuredData.OSD; using OSD = OpenMetaverse.StructuredData.OSD;
using OSDMap = OpenMetaverse.StructuredData.OSDMap; using OSDMap = OpenMetaverse.StructuredData.OSDMap;
[assembly: Addin("WebStats", "1.0")]
[assembly: AddinDependency("OpenSim", "0.5")]
namespace OpenSim.Region.UserStatistics namespace OpenSim.Region.UserStatistics
{ {
public class WebStatsModule : IRegionModule [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebStatsModule")]
public class WebStatsModule : ISharedRegionModule
{ {
private static readonly ILog m_log = private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -74,20 +79,23 @@ namespace OpenSim.Region.UserStatistics
private string m_loglines = String.Empty; private string m_loglines = String.Empty;
private volatile int lastHit = 12000; private volatile int lastHit = 12000;
public virtual void Initialise(Scene scene, IConfigSource config) #region ISharedRegionModule
public virtual void Initialise(IConfigSource config)
{ {
IConfig cnfg = config.Configs["WebStats"]; IConfig cnfg = config.Configs["WebStats"];
if (cnfg != null) if (cnfg != null)
enabled = cnfg.GetBoolean("enabled", false); enabled = cnfg.GetBoolean("enabled", false);
}
public virtual void PostInitialise()
{
if (!enabled) if (!enabled)
return; return;
lock (m_scenes) AddEventHandlers();
{
if (m_scenes.Count == 0)
{
if (Util.IsWindows()) if (Util.IsWindows())
Util.LoadArchSpecificWindowsDll("sqlite3.dll"); Util.LoadArchSpecificWindowsDll("sqlite3.dll");
@ -127,6 +135,13 @@ namespace OpenSim.Region.UserStatistics
MainServer.Instance.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest); MainServer.Instance.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest);
} }
public virtual void AddRegion(Scene scene)
{
if (!enabled)
return;
lock (m_scenes)
{
m_scenes.Add(scene); m_scenes.Add(scene);
if (m_simstatsCounters.ContainsKey(scene.RegionInfo.RegionID)) if (m_simstatsCounters.ContainsKey(scene.RegionInfo.RegionID))
m_simstatsCounters.Remove(scene.RegionInfo.RegionID); m_simstatsCounters.Remove(scene.RegionInfo.RegionID);
@ -136,6 +151,39 @@ namespace OpenSim.Region.UserStatistics
} }
} }
public void RegionLoaded(Scene scene)
{
}
public void RemoveRegion(Scene scene)
{
}
public virtual void Close()
{
if (!enabled)
return;
dbConn.Close();
dbConn.Dispose();
m_sessions.Clear();
m_scenes.Clear();
reports.Clear();
m_simstatsCounters.Clear();
}
public virtual string Name
{
get { return "ViewerStatsModule"; }
}
public Type ReplaceableInterface
{
get { return null; }
}
#endregion
private void ReceiveClassicSimStatsPacket(SimStats stats) private void ReceiveClassicSimStatsPacket(SimStats stats)
{ {
if (!enabled) if (!enabled)
@ -251,37 +299,6 @@ namespace OpenSim.Region.UserStatistics
} }
} }
public virtual void PostInitialise()
{
if (!enabled)
return;
AddHandlers();
}
public virtual void Close()
{
if (!enabled)
return;
dbConn.Close();
dbConn.Dispose();
m_sessions.Clear();
m_scenes.Clear();
reports.Clear();
m_simstatsCounters.Clear();
}
public virtual string Name
{
get { return "ViewerStatsModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
private void OnRegisterCaps(UUID agentID, Caps caps) private void OnRegisterCaps(UUID agentID, Caps caps)
{ {
// m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); // m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps);
@ -302,7 +319,7 @@ namespace OpenSim.Region.UserStatistics
{ {
} }
protected virtual void AddHandlers() protected virtual void AddEventHandlers()
{ {
lock (m_scenes) lock (m_scenes)
{ {