aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs')
-rw-r--r--OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs228
1 files changed, 0 insertions, 228 deletions
diff --git a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs b/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
deleted file mode 100644
index 3243a9a..0000000
--- a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
+++ /dev/null
@@ -1,228 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using System.Text;
33using Mono.Data.SqliteClient;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Framework.Monitoring;
38
39namespace OpenSim.Region.UserStatistics
40{
41 public class ActiveConnectionsAJAX : IStatsController
42 {
43 private Vector3 DefaultNeighborPosition = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 70);
44
45 #region IStatsController Members
46
47 public string ReportName
48 {
49 get { return ""; }
50 }
51
52 public Hashtable ProcessModel(Hashtable pParams)
53 {
54
55 List<Scene> m_scene = (List<Scene>)pParams["Scenes"];
56
57 Hashtable nh = new Hashtable();
58 nh.Add("hdata", m_scene);
59
60 return nh;
61 }
62
63 public string RenderView(Hashtable pModelResult)
64 {
65 List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"];
66
67 StringBuilder output = new StringBuilder();
68 HTMLUtil.OL_O(ref output, "");
69 foreach (Scene scene in all_scenes)
70 {
71 HTMLUtil.LI_O(ref output, String.Empty);
72 output.Append(scene.RegionInfo.RegionName);
73 HTMLUtil.OL_O(ref output, String.Empty);
74 scene.ForEachScenePresence(delegate(ScenePresence av)
75 {
76 Dictionary<string, string> queues = new Dictionary<string, string>();
77 if (av.ControllingClient is IStatsCollector)
78 {
79 IStatsCollector isClient = (IStatsCollector)av.ControllingClient;
80 queues = decodeQueueReport(isClient.Report());
81 }
82 HTMLUtil.LI_O(ref output, String.Empty);
83 output.Append(av.Name);
84 output.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
85 output.Append((av.IsChildAgent ? "Child" : "Root"));
86 if (av.AbsolutePosition == DefaultNeighborPosition)
87 {
88 output.Append("<br />Position: ?");
89 }
90 else
91 {
92 output.Append(string.Format("<br /><NOBR>Position: <{0},{1},{2}></NOBR>", (int)av.AbsolutePosition.X,
93 (int)av.AbsolutePosition.Y,
94 (int)av.AbsolutePosition.Z));
95 }
96 Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1));
97
98 HTMLUtil.UL_O(ref output, String.Empty);
99
100 foreach (string throttlename in throttles.Keys)
101 {
102 HTMLUtil.LI_O(ref output, String.Empty);
103 output.Append(throttlename);
104 output.Append(":");
105 output.Append(throttles[throttlename].ToString());
106 if (queues.ContainsKey(throttlename))
107 {
108 output.Append("/");
109 output.Append(queues[throttlename]);
110 }
111 HTMLUtil.LI_C(ref output);
112 }
113 if (queues.ContainsKey("Incoming") && queues.ContainsKey("Outgoing"))
114 {
115 HTMLUtil.LI_O(ref output, "red");
116 output.Append("SEND:");
117 output.Append(queues["Outgoing"]);
118 output.Append("/");
119 output.Append(queues["Incoming"]);
120 HTMLUtil.LI_C(ref output);
121 }
122
123 HTMLUtil.UL_C(ref output);
124 HTMLUtil.LI_C(ref output);
125 });
126 HTMLUtil.OL_C(ref output);
127 }
128 HTMLUtil.OL_C(ref output);
129 return output.ToString();
130 }
131
132 public Dictionary<string, int> DecodeClientThrottles(byte[] throttle)
133 {
134 Dictionary<string, int> returndict = new Dictionary<string, int>();
135 // From mantis http://opensimulator.org/mantis/view.php?id=1374
136 // it appears that sometimes we are receiving empty throttle byte arrays.
137 // TODO: Investigate this behaviour
138 if (throttle.Length == 0)
139 {
140 return new Dictionary<string, int>();
141 }
142
143 int tResend = -1;
144 int tLand = -1;
145 int tWind = -1;
146 int tCloud = -1;
147 int tTask = -1;
148 int tTexture = -1;
149 int tAsset = -1;
150 int tall = -1;
151 const int singlefloat = 4;
152
153 //Agent Throttle Block contains 7 single floatingpoint values.
154 int j = 0;
155
156 // Some Systems may be big endian...
157 // it might be smart to do this check more often...
158 if (!BitConverter.IsLittleEndian)
159 for (int i = 0; i < 7; i++)
160 Array.Reverse(throttle, j + i * singlefloat, singlefloat);
161
162 // values gotten from OpenMetaverse.org/wiki/Throttle. Thanks MW_
163 // bytes
164 // Convert to integer, since.. the full fp space isn't used.
165 tResend = (int)BitConverter.ToSingle(throttle, j);
166 returndict.Add("Resend", tResend);
167 j += singlefloat;
168 tLand = (int)BitConverter.ToSingle(throttle, j);
169 returndict.Add("Land", tLand);
170 j += singlefloat;
171 tWind = (int)BitConverter.ToSingle(throttle, j);
172 returndict.Add("Wind", tWind);
173 j += singlefloat;
174 tCloud = (int)BitConverter.ToSingle(throttle, j);
175 returndict.Add("Cloud", tCloud);
176 j += singlefloat;
177 tTask = (int)BitConverter.ToSingle(throttle, j);
178 returndict.Add("Task", tTask);
179 j += singlefloat;
180 tTexture = (int)BitConverter.ToSingle(throttle, j);
181 returndict.Add("Texture", tTexture);
182 j += singlefloat;
183 tAsset = (int)BitConverter.ToSingle(throttle, j);
184 returndict.Add("Asset", tAsset);
185
186 tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset;
187 returndict.Add("All", tall);
188
189 return returndict;
190 }
191 public Dictionary<string,string> decodeQueueReport(string rep)
192 {
193 Dictionary<string, string> returndic = new Dictionary<string, string>();
194 if (rep.Length == 79)
195 {
196 int pos = 1;
197 returndic.Add("All", rep.Substring((6 * pos), 8)); pos++;
198 returndic.Add("Incoming", rep.Substring((7 * pos), 8)); pos++;
199 returndic.Add("Outgoing", rep.Substring((7 * pos) , 8)); pos++;
200 returndic.Add("Resend", rep.Substring((7 * pos) , 8)); pos++;
201 returndic.Add("Land", rep.Substring((7 * pos) , 8)); pos++;
202 returndic.Add("Wind", rep.Substring((7 * pos) , 8)); pos++;
203 returndic.Add("Cloud", rep.Substring((7 * pos) , 8)); pos++;
204 returndic.Add("Task", rep.Substring((7 * pos) , 8)); pos++;
205 returndic.Add("Texture", rep.Substring((7 * pos), 8)); pos++;
206 returndic.Add("Asset", rep.Substring((7 * pos), 8));
207 /*
208 * return string.Format("{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}",
209 SendQueue.Count(),
210 IncomingPacketQueue.Count,
211 OutgoingPacketQueue.Count,
212 ResendOutgoingPacketQueue.Count,
213 LandOutgoingPacketQueue.Count,
214 WindOutgoingPacketQueue.Count,
215 CloudOutgoingPacketQueue.Count,
216 TaskOutgoingPacketQueue.Count,
217 TextureOutgoingPacketQueue.Count,
218 AssetOutgoingPacketQueue.Count);
219 */
220 }
221
222
223
224 return returndic;
225 }
226 #endregion
227 }
228}