diff options
author | Diva Canto | 2012-11-11 17:02:22 -0800 |
---|---|---|
committer | Diva Canto | 2012-11-11 17:02:22 -0800 |
commit | 113a9704f286077c64c2f51c59503b64bf681734 (patch) | |
tree | 02b12c4f29aed926495d074f3b27a2766e9ca785 /OpenSim/Region | |
parent | Two more modules converted: XmlRpcGridRouterModule and XmlRpcRouterModule. (diff) | |
download | opensim-SC_OLD-113a9704f286077c64c2f51c59503b64bf681734.zip opensim-SC_OLD-113a9704f286077c64c2f51c59503b64bf681734.tar.gz opensim-SC_OLD-113a9704f286077c64c2f51c59503b64bf681734.tar.bz2 opensim-SC_OLD-113a9704f286077c64c2f51c59503b64bf681734.tar.xz |
One more module converted: WebStatsModule.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/UserStatistics/WebStatsModule.cs | 169 |
1 files changed, 93 insertions, 76 deletions
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index 625eba4..b08233c 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs | |||
@@ -43,15 +43,20 @@ using OpenSim.Framework.Servers.HttpServer; | |||
43 | using OpenSim.Region.Framework.Interfaces; | 43 | using OpenSim.Region.Framework.Interfaces; |
44 | using OpenSim.Region.Framework.Scenes; | 44 | using OpenSim.Region.Framework.Scenes; |
45 | using Mono.Data.SqliteClient; | 45 | using Mono.Data.SqliteClient; |
46 | using Mono.Addins; | ||
46 | 47 | ||
47 | using Caps = OpenSim.Framework.Capabilities.Caps; | 48 | using Caps = OpenSim.Framework.Capabilities.Caps; |
48 | 49 | ||
49 | using OSD = OpenMetaverse.StructuredData.OSD; | 50 | using OSD = OpenMetaverse.StructuredData.OSD; |
50 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | 51 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; |
51 | 52 | ||
53 | [assembly: Addin("WebStats", "1.0")] | ||
54 | [assembly: AddinDependency("OpenSim", "0.5")] | ||
55 | |||
52 | namespace OpenSim.Region.UserStatistics | 56 | namespace OpenSim.Region.UserStatistics |
53 | { | 57 | { |
54 | public class WebStatsModule : IRegionModule | 58 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebStatsModule")] |
59 | public class WebStatsModule : ISharedRegionModule | ||
55 | { | 60 | { |
56 | private static readonly ILog m_log = | 61 | private static readonly ILog m_log = |
57 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 62 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -74,59 +79,69 @@ namespace OpenSim.Region.UserStatistics | |||
74 | private string m_loglines = String.Empty; | 79 | private string m_loglines = String.Empty; |
75 | private volatile int lastHit = 12000; | 80 | private volatile int lastHit = 12000; |
76 | 81 | ||
77 | public virtual void Initialise(Scene scene, IConfigSource config) | 82 | #region ISharedRegionModule |
83 | |||
84 | public virtual void Initialise(IConfigSource config) | ||
78 | { | 85 | { |
79 | IConfig cnfg = config.Configs["WebStats"]; | 86 | IConfig cnfg = config.Configs["WebStats"]; |
80 | 87 | ||
81 | if (cnfg != null) | 88 | if (cnfg != null) |
82 | enabled = cnfg.GetBoolean("enabled", false); | 89 | enabled = cnfg.GetBoolean("enabled", false); |
83 | 90 | } | |
91 | |||
92 | public virtual void PostInitialise() | ||
93 | { | ||
94 | if (!enabled) | ||
95 | return; | ||
96 | |||
97 | AddEventHandlers(); | ||
98 | |||
99 | if (Util.IsWindows()) | ||
100 | Util.LoadArchSpecificWindowsDll("sqlite3.dll"); | ||
101 | |||
102 | //IConfig startupConfig = config.Configs["Startup"]; | ||
103 | |||
104 | dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3"); | ||
105 | dbConn.Open(); | ||
106 | CreateTables(dbConn); | ||
107 | |||
108 | Prototype_distributor protodep = new Prototype_distributor(); | ||
109 | Updater_distributor updatedep = new Updater_distributor(); | ||
110 | ActiveConnectionsAJAX ajConnections = new ActiveConnectionsAJAX(); | ||
111 | SimStatsAJAX ajSimStats = new SimStatsAJAX(); | ||
112 | LogLinesAJAX ajLogLines = new LogLinesAJAX(); | ||
113 | Default_Report defaultReport = new Default_Report(); | ||
114 | Clients_report clientReport = new Clients_report(); | ||
115 | Sessions_Report sessionsReport = new Sessions_Report(); | ||
116 | |||
117 | reports.Add("prototype.js", protodep); | ||
118 | reports.Add("updater.js", updatedep); | ||
119 | reports.Add("activeconnectionsajax.html", ajConnections); | ||
120 | reports.Add("simstatsajax.html", ajSimStats); | ||
121 | reports.Add("activelogajax.html", ajLogLines); | ||
122 | reports.Add("default.report", defaultReport); | ||
123 | reports.Add("clients.report", clientReport); | ||
124 | reports.Add("sessions.report", sessionsReport); | ||
125 | |||
126 | //// | ||
127 | // Add Your own Reports here (Do Not Modify Lines here Devs!) | ||
128 | //// | ||
129 | |||
130 | //// | ||
131 | // End Own reports section | ||
132 | //// | ||
133 | |||
134 | MainServer.Instance.AddHTTPHandler("/SStats/", HandleStatsRequest); | ||
135 | MainServer.Instance.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest); | ||
136 | } | ||
137 | |||
138 | public virtual void AddRegion(Scene scene) | ||
139 | { | ||
84 | if (!enabled) | 140 | if (!enabled) |
85 | return; | 141 | return; |
86 | 142 | ||
87 | lock (m_scenes) | 143 | lock (m_scenes) |
88 | { | 144 | { |
89 | if (m_scenes.Count == 0) | ||
90 | { | ||
91 | if (Util.IsWindows()) | ||
92 | Util.LoadArchSpecificWindowsDll("sqlite3.dll"); | ||
93 | |||
94 | //IConfig startupConfig = config.Configs["Startup"]; | ||
95 | |||
96 | dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3"); | ||
97 | dbConn.Open(); | ||
98 | CreateTables(dbConn); | ||
99 | |||
100 | Prototype_distributor protodep = new Prototype_distributor(); | ||
101 | Updater_distributor updatedep = new Updater_distributor(); | ||
102 | ActiveConnectionsAJAX ajConnections = new ActiveConnectionsAJAX(); | ||
103 | SimStatsAJAX ajSimStats = new SimStatsAJAX(); | ||
104 | LogLinesAJAX ajLogLines = new LogLinesAJAX(); | ||
105 | Default_Report defaultReport = new Default_Report(); | ||
106 | Clients_report clientReport = new Clients_report(); | ||
107 | Sessions_Report sessionsReport = new Sessions_Report(); | ||
108 | |||
109 | reports.Add("prototype.js", protodep); | ||
110 | reports.Add("updater.js", updatedep); | ||
111 | reports.Add("activeconnectionsajax.html", ajConnections); | ||
112 | reports.Add("simstatsajax.html", ajSimStats); | ||
113 | reports.Add("activelogajax.html", ajLogLines); | ||
114 | reports.Add("default.report", defaultReport); | ||
115 | reports.Add("clients.report", clientReport); | ||
116 | reports.Add("sessions.report", sessionsReport); | ||
117 | |||
118 | //// | ||
119 | // Add Your own Reports here (Do Not Modify Lines here Devs!) | ||
120 | //// | ||
121 | |||
122 | //// | ||
123 | // End Own reports section | ||
124 | //// | ||
125 | |||
126 | MainServer.Instance.AddHTTPHandler("/SStats/", HandleStatsRequest); | ||
127 | MainServer.Instance.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest); | ||
128 | } | ||
129 | |||
130 | m_scenes.Add(scene); | 145 | m_scenes.Add(scene); |
131 | if (m_simstatsCounters.ContainsKey(scene.RegionInfo.RegionID)) | 146 | if (m_simstatsCounters.ContainsKey(scene.RegionInfo.RegionID)) |
132 | m_simstatsCounters.Remove(scene.RegionInfo.RegionID); | 147 | m_simstatsCounters.Remove(scene.RegionInfo.RegionID); |
@@ -136,6 +151,39 @@ namespace OpenSim.Region.UserStatistics | |||
136 | } | 151 | } |
137 | } | 152 | } |
138 | 153 | ||
154 | public void RegionLoaded(Scene scene) | ||
155 | { | ||
156 | } | ||
157 | |||
158 | public void RemoveRegion(Scene scene) | ||
159 | { | ||
160 | } | ||
161 | |||
162 | public virtual void Close() | ||
163 | { | ||
164 | if (!enabled) | ||
165 | return; | ||
166 | |||
167 | dbConn.Close(); | ||
168 | dbConn.Dispose(); | ||
169 | m_sessions.Clear(); | ||
170 | m_scenes.Clear(); | ||
171 | reports.Clear(); | ||
172 | m_simstatsCounters.Clear(); | ||
173 | } | ||
174 | |||
175 | public virtual string Name | ||
176 | { | ||
177 | get { return "ViewerStatsModule"; } | ||
178 | } | ||
179 | |||
180 | public Type ReplaceableInterface | ||
181 | { | ||
182 | get { return null; } | ||
183 | } | ||
184 | |||
185 | #endregion | ||
186 | |||
139 | private void ReceiveClassicSimStatsPacket(SimStats stats) | 187 | private void ReceiveClassicSimStatsPacket(SimStats stats) |
140 | { | 188 | { |
141 | if (!enabled) | 189 | if (!enabled) |
@@ -251,37 +299,6 @@ namespace OpenSim.Region.UserStatistics | |||
251 | } | 299 | } |
252 | } | 300 | } |
253 | 301 | ||
254 | public virtual void PostInitialise() | ||
255 | { | ||
256 | if (!enabled) | ||
257 | return; | ||
258 | |||
259 | AddHandlers(); | ||
260 | } | ||
261 | |||
262 | public virtual void Close() | ||
263 | { | ||
264 | if (!enabled) | ||
265 | return; | ||
266 | |||
267 | dbConn.Close(); | ||
268 | dbConn.Dispose(); | ||
269 | m_sessions.Clear(); | ||
270 | m_scenes.Clear(); | ||
271 | reports.Clear(); | ||
272 | m_simstatsCounters.Clear(); | ||
273 | } | ||
274 | |||
275 | public virtual string Name | ||
276 | { | ||
277 | get { return "ViewerStatsModule"; } | ||
278 | } | ||
279 | |||
280 | public bool IsSharedModule | ||
281 | { | ||
282 | get { return true; } | ||
283 | } | ||
284 | |||
285 | private void OnRegisterCaps(UUID agentID, Caps caps) | 302 | private void OnRegisterCaps(UUID agentID, Caps caps) |
286 | { | 303 | { |
287 | // m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); | 304 | // m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); |
@@ -302,7 +319,7 @@ namespace OpenSim.Region.UserStatistics | |||
302 | { | 319 | { |
303 | } | 320 | } |
304 | 321 | ||
305 | protected virtual void AddHandlers() | 322 | protected virtual void AddEventHandlers() |
306 | { | 323 | { |
307 | lock (m_scenes) | 324 | lock (m_scenes) |
308 | { | 325 | { |