From 119104e35bc02e15a1ce08175ca6408fb8e9f7be Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 21 Dec 2008 00:11:54 +0000 Subject: [PATCH] * Re-implement packet tracking in IClientAPI so we can see what's going on in the client network in the simstats manager. This makes packets in per second, packets out per second, and unacked bytes work again in the simulator stats section. --- OpenSim/Framework/IClientAPI.cs | 6 +++--- .../Region/ClientStack/LindenUDP/LLClientView.cs | 16 +++++++++++++++- .../Environment/Modules/World/NPC/NPCAvatar.cs | 1 + OpenSim/Region/Environment/Scenes/Scene.cs | 3 +++ .../Environment/Scenes/SimStatsReporter.cs | 8 ++++++++ .../Examples/SimpleModule/MyNpcCharacter.cs | 1 + OpenSim/Tests/Common/Mock/TestClient.cs | 1 + 7 files changed, 32 insertions(+), 4 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index a9c05f6f3b..e3163d7a12 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -47,9 +47,6 @@ namespace OpenSim.Framework public delegate void ImprovedInstantMessage(IClientAPI remoteclient, GridInstantMessage im); - // This shouldn't be cut down... - // especially if we're ever going to implement groups, presence, estate message dialogs... - public delegate void RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, bool RezSelected, bool RemoveItem, UUID fromTaskID); @@ -63,6 +60,8 @@ namespace OpenSim.Framework float height, float seconds, byte size, byte action, float north, float west, float south, float east, UUID agentId); + public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); + public delegate void SetAppearance(byte[] texture, List visualParamList); public delegate void StartAnim(IClientAPI remoteClient, UUID animID); @@ -722,6 +721,7 @@ namespace OpenSim.Framework event StartLure OnStartLure; event TeleportLureRequest OnTeleportLureRequest; + event NetworkStats OnNetworkStatsUpdate; // void ActivateGesture(UUID assetId, UUID gestureId); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 5ce52352a3..9d8ecf0274 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -272,6 +272,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP private StartLure handlerStartLure; private TeleportLureRequest handlerTeleportLureRequest; + private NetworkStats handlerNetworkStatsUpdate; + private readonly IGroupsModule m_GroupsModule; //private TerrainUnacked handlerUnackedTerrain = null; @@ -450,7 +452,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_PacketHandler = new LLPacketHandler(this, m_networkServer, userSettings); m_PacketHandler.SynchronizeClient = SynchronizeClient; - + m_PacketHandler.OnPacketStats += PopulateStats; + RegisterLocalPacketHandlers(); m_clientThread = new Thread(Start); @@ -572,6 +575,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void Terminate() { + m_PacketHandler.OnPacketStats -= PopulateStats; m_PacketHandler.Stop(); // wait for thread stoped @@ -585,6 +589,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP # region Packet Handling + public void PopulateStats(int inPackets, int outPackets, int unAckedBytes) + { + handlerNetworkStatsUpdate = OnNetworkStatsUpdate; + if (handlerNetworkStatsUpdate != null) + { + handlerNetworkStatsUpdate(inPackets, outPackets, unAckedBytes); + } + } + public static bool AddPacketHandler(PacketType packetType, PacketMethod handler) { bool result = false; @@ -1017,6 +1030,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event StartLure OnStartLure; public event TeleportLureRequest OnTeleportLureRequest; + public event NetworkStats OnNetworkStatsUpdate; public void ActivateGesture(UUID assetId, UUID gestureId) diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs index 66662a02a2..6ca2bb412c 100644 --- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs @@ -344,6 +344,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC public event StartLure OnStartLure; public event TeleportLureRequest OnTeleportLureRequest; + public event NetworkStats OnNetworkStatsUpdate; #pragma warning restore 67 diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 2b8ee7461d..5bc416f4d2 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -2346,6 +2346,9 @@ namespace OpenSim.Region.Environment.Scenes client.OnSoundTrigger += soundModule.TriggerSound; client.OnObjectOwner += ObjectOwner; + + if (m_statsReporter != null) + client.OnNetworkStatsUpdate += m_statsReporter.AddPacketsFromClientStats; // EventManager.TriggerOnNewClient(client); } diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs index 70287fc341..c614f7887f 100644 --- a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs @@ -409,6 +409,14 @@ namespace OpenSim.Region.Environment.Scenes return lastReportedSimFPS; } + public void AddPacketsFromClientStats(int inPackets, int outPackets, int unAckedBytes) + { + AddInPackets(inPackets); + AddOutPackets(outPackets); + AddunAckedBytes(unAckedBytes); + + } + #endregion } } diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 35b5233a99..4cd5187ee9 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -239,6 +239,7 @@ namespace OpenSim.Region.Examples.SimpleModule public event StartLure OnStartLure; public event TeleportLureRequest OnTeleportLureRequest; + public event NetworkStats OnNetworkStatsUpdate; #pragma warning restore 67 diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 1bcf829ab3..70a2d11e8f 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -235,6 +235,7 @@ namespace OpenSim.Tests.Common.Mock public event StartLure OnStartLure; public event TeleportLureRequest OnTeleportLureRequest; + public event NetworkStats OnNetworkStatsUpdate; #pragma warning restore 67