aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-09-24 23:03:39 +0100
committerJustin Clark-Casey (justincc)2014-09-24 23:44:48 +0100
commit6ac12a42ec81dbd7538c61554e410893000e5fb3 (patch)
tree127a87105db293bfd1aece0dfac6edf5ceff89e6
parentRemove an unnecessary check at the bottom of Scene.CloseAgent() (diff)
downloadopensim-SC-6ac12a42ec81dbd7538c61554e410893000e5fb3.zip
opensim-SC-6ac12a42ec81dbd7538c61554e410893000e5fb3.tar.gz
opensim-SC-6ac12a42ec81dbd7538c61554e410893000e5fb3.tar.bz2
opensim-SC-6ac12a42ec81dbd7538c61554e410893000e5fb3.tar.xz
Add "debug lludp packet" command to pCampbot.
This allows one to log the packets received by a particular bot that are not duplicates of already received packets. Similar to the OpenSimulator command at the same name but currently any positive level logs all received packets. No facility yet for logging outgoing packets. For debug purposes.
Diffstat (limited to '')
-rw-r--r--OpenSim/Tools/pCampBot/Bot.cs39
-rw-r--r--OpenSim/Tools/pCampBot/BotManager.cs42
2 files changed, 81 insertions, 0 deletions
diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs
index 45a6682..4f28733 100644
--- a/OpenSim/Tools/pCampBot/Bot.cs
+++ b/OpenSim/Tools/pCampBot/Bot.cs
@@ -35,6 +35,7 @@ using System.Timers;
35using log4net; 35using log4net;
36using OpenMetaverse; 36using OpenMetaverse;
37using OpenMetaverse.Assets; 37using OpenMetaverse.Assets;
38using OpenMetaverse.Packets;
38using Nini.Config; 39using Nini.Config;
39using OpenSim.Framework; 40using OpenSim.Framework;
40using OpenSim.Framework.Console; 41using OpenSim.Framework.Console;
@@ -56,6 +57,27 @@ namespace pCampBot
56 { 57 {
57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 58 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58 59
60 public int PacketDebugLevel
61 {
62 get { return m_packetDebugLevel; }
63 set
64 {
65 if (value == m_packetDebugLevel)
66 return;
67
68 m_packetDebugLevel = value;
69
70 if (Client != null)
71 {
72 if (m_packetDebugLevel <= 0)
73 Client.Network.UnregisterCallback(PacketType.Default, PacketReceivedDebugHandler);
74 else
75 Client.Network.RegisterCallback(PacketType.Default, PacketReceivedDebugHandler, false);
76 }
77 }
78 }
79 private int m_packetDebugLevel;
80
59 public delegate void AnEvent(Bot callbot, EventType someevent); // event delegate for bot events 81 public delegate void AnEvent(Bot callbot, EventType someevent); // event delegate for bot events
60 82
61 /// <summary> 83 /// <summary>
@@ -231,6 +253,9 @@ namespace pCampBot
231 253
232 if (Client != null) 254 if (Client != null)
233 { 255 {
256 // Remove any registered debug handlers
257 Client.Network.UnregisterCallback(PacketType.Default, PacketReceivedDebugHandler);
258
234 newClient.Settings.LOGIN_SERVER = Client.Settings.LOGIN_SERVER; 259 newClient.Settings.LOGIN_SERVER = Client.Settings.LOGIN_SERVER;
235 newClient.Settings.ALWAYS_DECODE_OBJECTS = Client.Settings.ALWAYS_DECODE_OBJECTS; 260 newClient.Settings.ALWAYS_DECODE_OBJECTS = Client.Settings.ALWAYS_DECODE_OBJECTS;
236 newClient.Settings.AVATAR_TRACKING = Client.Settings.AVATAR_TRACKING; 261 newClient.Settings.AVATAR_TRACKING = Client.Settings.AVATAR_TRACKING;
@@ -273,6 +298,9 @@ namespace pCampBot
273 newClient.Network.Disconnected += Network_OnDisconnected; 298 newClient.Network.Disconnected += Network_OnDisconnected;
274 newClient.Objects.ObjectUpdate += Objects_NewPrim; 299 newClient.Objects.ObjectUpdate += Objects_NewPrim;
275 300
301 if (m_packetDebugLevel > 0)
302 newClient.Network.RegisterCallback(PacketType.Default, PacketReceivedDebugHandler);
303
276 Client = newClient; 304 Client = newClient;
277 } 305 }
278 306
@@ -705,5 +733,16 @@ namespace pCampBot
705// SaveAsset((AssetWearable) asset); 733// SaveAsset((AssetWearable) asset);
706// } 734// }
707 } 735 }
736
737 private void PacketReceivedDebugHandler(object o, PacketReceivedEventArgs args)
738 {
739 Packet p = args.Packet;
740 Header h = p.Header;
741 Simulator s = args.Simulator;
742
743 m_log.DebugFormat(
744 "[BOT]: Bot {0} received from {1} packet {2} #{3}, rel {4}, res {5}",
745 Name, s.Name, p.Type, h.Sequence, h.Reliable, h.Resent);
746 }
708 } 747 }
709} 748}
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index c7d8f05..46094d6 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -254,6 +254,16 @@ namespace pCampBot
254 "Shows the detailed status and settings of a particular bot.", HandleShowBotStatus); 254 "Shows the detailed status and settings of a particular bot.", HandleShowBotStatus);
255 255
256 m_console.Commands.AddCommand( 256 m_console.Commands.AddCommand(
257 "Debug",
258 false,
259 "debug lludp packet",
260 "debug lludp packet <level> <avatar-first-name> <avatar-last-name>",
261 "Turn on received packet logging.",
262 "If level > 0 then all received packets that are not duplicates are logged.\n"
263 + "If level <= 0 then no received packets are logged.",
264 HandleDebugLludpPacketCommand);
265
266 m_console.Commands.AddCommand(
257 "Bots", false, "show status", "show status", "Shows pCampbot status.", HandleShowStatus); 267 "Bots", false, "show status", "show status", "Shows pCampbot status.", HandleShowStatus);
258 268
259 m_bots = new List<Bot>(); 269 m_bots = new List<Bot>();
@@ -784,6 +794,38 @@ namespace pCampBot
784 } 794 }
785 } 795 }
786 796
797 private void HandleDebugLludpPacketCommand(string module, string[] args)
798 {
799 if (args.Length != 6)
800 {
801 MainConsole.Instance.OutputFormat("Usage: debug lludp packet <level> <bot-first-name> <bot-last-name>");
802 return;
803 }
804
805 int level;
806
807 if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[3], out level))
808 return;
809
810 string botFirstName = args[4];
811 string botLastName = args[5];
812
813 Bot bot;
814
815 lock (m_bots)
816 bot = m_bots.FirstOrDefault(b => b.FirstName == botFirstName && b.LastName == botLastName);
817
818 if (bot == null)
819 {
820 MainConsole.Instance.OutputFormat("No bot named {0} {1}", botFirstName, botLastName);
821 return;
822 }
823
824 bot.PacketDebugLevel = level;
825
826 MainConsole.Instance.OutputFormat("Set debug level of {0} to {1}", bot.Name, bot.PacketDebugLevel);
827 }
828
787 private void HandleShowRegions(string module, string[] cmd) 829 private void HandleShowRegions(string module, string[] cmd)
788 { 830 {
789 string outputFormat = "{0,-30} {1, -20} {2, -5} {3, -5}"; 831 string outputFormat = "{0,-30} {1, -20} {2, -5} {3, -5}";