123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Reflection;
- using System.Text;
- using Mono.Data.SqliteClient;
- using OpenMetaverse;
- using OpenSim.Framework;
- using OpenSim.Region.Framework.Scenes;
- using OpenSim.Framework.Statistics;
- namespace OpenSim.Region.UserStatistics
- {
- public class ActiveConnectionsAJAX : IStatsController
- {
- private Vector3 DefaultNeighborPosition = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 70);
- #region IStatsController Members
- public string ReportName
- {
- get { return ""; }
- }
- public Hashtable ProcessModel(Hashtable pParams)
- {
-
- List<Scene> m_scene = (List<Scene>)pParams["Scenes"];
- Hashtable nh = new Hashtable();
- nh.Add("hdata", m_scene);
- return nh;
- }
- public string RenderView(Hashtable pModelResult)
- {
- List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"];
- StringBuilder output = new StringBuilder();
- HTMLUtil.OL_O(ref output, "");
- foreach (Scene scene in all_scenes)
- {
- HTMLUtil.LI_O(ref output, String.Empty);
- output.Append(scene.RegionInfo.RegionName);
- HTMLUtil.OL_O(ref output, String.Empty);
- scene.ForEachScenePresence(delegate(ScenePresence av)
- {
- Dictionary<string, string> queues = new Dictionary<string, string>();
- if (av.ControllingClient is IStatsCollector)
- {
- IStatsCollector isClient = (IStatsCollector)av.ControllingClient;
- queues = decodeQueueReport(isClient.Report());
- }
- HTMLUtil.LI_O(ref output, String.Empty);
- output.Append(av.Name);
- output.Append(" ");
- output.Append((av.IsChildAgent ? "Child" : "Root"));
- if (av.AbsolutePosition == DefaultNeighborPosition)
- {
- output.Append("<br />Position: ?");
- }
- else
- {
- output.Append(string.Format("<br /><NOBR>Position: <{0},{1},{2}></NOBR>", (int)av.AbsolutePosition.X,
- (int)av.AbsolutePosition.Y,
- (int)av.AbsolutePosition.Z));
- }
- Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1));
- HTMLUtil.UL_O(ref output, String.Empty);
- foreach (string throttlename in throttles.Keys)
- {
- HTMLUtil.LI_O(ref output, String.Empty);
- output.Append(throttlename);
- output.Append(":");
- output.Append(throttles[throttlename].ToString());
- if (queues.ContainsKey(throttlename))
- {
- output.Append("/");
- output.Append(queues[throttlename]);
- }
- HTMLUtil.LI_C(ref output);
- }
- if (queues.ContainsKey("Incoming") && queues.ContainsKey("Outgoing"))
- {
- HTMLUtil.LI_O(ref output, "red");
- output.Append("SEND:");
- output.Append(queues["Outgoing"]);
- output.Append("/");
- output.Append(queues["Incoming"]);
- HTMLUtil.LI_C(ref output);
- }
- HTMLUtil.UL_C(ref output);
- HTMLUtil.LI_C(ref output);
- });
- HTMLUtil.OL_C(ref output);
- }
- HTMLUtil.OL_C(ref output);
- return output.ToString();
- }
- public Dictionary<string, int> DecodeClientThrottles(byte[] throttle)
- {
- Dictionary<string, int> returndict = new Dictionary<string, int>();
-
-
-
- if (throttle.Length == 0)
- {
- return new Dictionary<string, int>();
- }
- int tResend = -1;
- int tLand = -1;
- int tWind = -1;
- int tCloud = -1;
- int tTask = -1;
- int tTexture = -1;
- int tAsset = -1;
- int tall = -1;
- const int singlefloat = 4;
-
- int j = 0;
-
-
- if (!BitConverter.IsLittleEndian)
- for (int i = 0; i < 7; i++)
- Array.Reverse(throttle, j + i * singlefloat, singlefloat);
-
-
-
- tResend = (int)BitConverter.ToSingle(throttle, j);
- returndict.Add("Resend", tResend);
- j += singlefloat;
- tLand = (int)BitConverter.ToSingle(throttle, j);
- returndict.Add("Land", tLand);
- j += singlefloat;
- tWind = (int)BitConverter.ToSingle(throttle, j);
- returndict.Add("Wind", tWind);
- j += singlefloat;
- tCloud = (int)BitConverter.ToSingle(throttle, j);
- returndict.Add("Cloud", tCloud);
- j += singlefloat;
- tTask = (int)BitConverter.ToSingle(throttle, j);
- returndict.Add("Task", tTask);
- j += singlefloat;
- tTexture = (int)BitConverter.ToSingle(throttle, j);
- returndict.Add("Texture", tTexture);
- j += singlefloat;
- tAsset = (int)BitConverter.ToSingle(throttle, j);
- returndict.Add("Asset", tAsset);
- tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset;
- returndict.Add("All", tall);
- return returndict;
- }
- public Dictionary<string,string> decodeQueueReport(string rep)
- {
- Dictionary<string, string> returndic = new Dictionary<string, string>();
- if (rep.Length == 79)
- {
- int pos = 1;
- returndic.Add("All", rep.Substring((6 * pos), 8)); pos++;
- returndic.Add("Incoming", rep.Substring((7 * pos), 8)); pos++;
- returndic.Add("Outgoing", rep.Substring((7 * pos) , 8)); pos++;
- returndic.Add("Resend", rep.Substring((7 * pos) , 8)); pos++;
- returndic.Add("Land", rep.Substring((7 * pos) , 8)); pos++;
- returndic.Add("Wind", rep.Substring((7 * pos) , 8)); pos++;
- returndic.Add("Cloud", rep.Substring((7 * pos) , 8)); pos++;
- returndic.Add("Task", rep.Substring((7 * pos) , 8)); pos++;
- returndic.Add("Texture", rep.Substring((7 * pos), 8)); pos++;
- returndic.Add("Asset", rep.Substring((7 * pos), 8));
-
- }
- return returndic;
- }
- #endregion
- }
- }
|