TestClient cleanup

This commit is contained in:
Cinder
2022-02-25 19:38:11 -06:00
parent 3fe7b935e7
commit 781a63c307
84 changed files with 385 additions and 408 deletions

View File

@@ -26,21 +26,17 @@ namespace OpenMetaverse.TestClient
CommandCategory cc;
foreach (Command c in Client.Commands.Values)
{
if (c.Category.Equals(null))
cc = CommandCategory.Unknown;
else
cc = c.Category;
{
cc = c.Category.Equals(null) ? CommandCategory.Unknown : c.Category;
if (CommandTree.ContainsKey(cc))
CommandTree[cc].Add(c);
else
{
List<Command> l = new List<Command>();
l.Add(c);
List<Command> l = new List<Command> { c };
CommandTree.Add(cc, l);
}
}
}
foreach (KeyValuePair<CommandCategory, List<Command>> kvp in CommandTree)
{

View File

@@ -23,22 +23,20 @@ namespace OpenMetaverse.TestClient
public override string Execute(string[] args, UUID fromAgentID)
{
if (args.Length != 2)
return string.Format("Usage: {0} no-of-packets filename", Name);
return $"Usage: {Name} no-of-packets filename";
string rawNumberOfPackets = args[0];
string path = args[1];
int numberOfPackets;
if (!int.TryParse(args[0], out numberOfPackets) || numberOfPackets <= 0)
return string.Format(
"{0} is not a valid number of packets for {1}", rawNumberOfPackets, m_client.Self.Name);
return $"{rawNumberOfPackets} is not a valid number of packets for {m_client.Self.Name}";
lock (this)
{
if (m_isLogging)
return string.Format(
"Still waiting to finish logging {0} packets for {1}",
m_packetsToLogRemaining, m_client.Self.Name);
return
$"Still waiting to finish logging {m_packetsToLogRemaining} packets for {m_client.Self.Name}";
try
{
@@ -46,7 +44,7 @@ namespace OpenMetaverse.TestClient
}
catch (Exception e)
{
return string.Format("Could not open file with path [{0}], exception {1}", path, e);
return $"Could not open file with path [{path}], exception {e}";
}
m_isLogging = true;
@@ -54,7 +52,7 @@ namespace OpenMetaverse.TestClient
m_packetsToLogRemaining = numberOfPackets;
m_client.Network.RegisterCallback(PacketType.Default, HandlePacket);
return string.Format("Now logging {0} packets for {1}", m_packetsToLogRemaining, m_client.Self.Name);
return $"Now logging {m_packetsToLogRemaining} packets for {m_client.Self.Name}";
}
/// <summary>

View File

@@ -48,7 +48,7 @@ namespace OpenMetaverse.TestClient
Client.Self.InstantMessage(
Client.MasterKey, "You are now my master. IM me with \"help\" for a command list.");
return String.Format("Master set to {0} ({1})", masterName, Client.MasterKey.ToString());
return $"Master set to {masterName} ({Client.MasterKey.ToString()})";
}
private void KeyResolvHandler(object sender, DirPeopleReplyEventArgs e)

View File

@@ -34,7 +34,7 @@ namespace OpenMetaverse.TestClient
}
}
return "Master set to " + Client.MasterKey.ToString();
return "Master set to " + Client.MasterKey;
}
}
}

View File

@@ -12,9 +12,9 @@ namespace OpenMetaverse.TestClient
Description = "Prints out information for every viewer effect that is received. Usage: showeffects [on/off]";
Category = CommandCategory.Other;
testClient.Avatars.ViewerEffect += new EventHandler<ViewerEffectEventArgs>(Avatars_ViewerEffect);
testClient.Avatars.ViewerEffectPointAt += new EventHandler<ViewerEffectPointAtEventArgs>(Avatars_ViewerEffectPointAt);
testClient.Avatars.ViewerEffectLookAt += new EventHandler<ViewerEffectLookAtEventArgs>(Avatars_ViewerEffectLookAt);
testClient.Avatars.ViewerEffect += Avatars_ViewerEffect;
testClient.Avatars.ViewerEffectPointAt += Avatars_ViewerEffectPointAt;
testClient.Avatars.ViewerEffectLookAt += Avatars_ViewerEffectLookAt;
}
void Avatars_ViewerEffectLookAt(object sender, ViewerEffectLookAtEventArgs e)

View File

@@ -17,23 +17,33 @@ namespace OpenMetaverse.TestClient
public override string Execute(string[] args, UUID fromAgentID)
{
int seconds;
if (args.Length != 1 || !Int32.TryParse(args[0], out seconds))
if (args.Length != 1 || !int.TryParse(args[0], out seconds))
return "Usage: sleep [seconds]";
AgentPausePacket pause = new AgentPausePacket();
pause.AgentData.AgentID = Client.Self.AgentID;
pause.AgentData.SessionID = Client.Self.SessionID;
pause.AgentData.SerialNum = sleepSerialNum++;
AgentPausePacket pause = new AgentPausePacket
{
AgentData =
{
AgentID = Client.Self.AgentID,
SessionID = Client.Self.SessionID,
SerialNum = sleepSerialNum++
}
};
Client.Network.SendPacket(pause);
// Sleep
System.Threading.Thread.Sleep(seconds * 1000);
AgentResumePacket resume = new AgentResumePacket();
resume.AgentData.AgentID = Client.Self.AgentID;
resume.AgentData.SessionID = Client.Self.SessionID;
resume.AgentData.SerialNum = pause.AgentData.SerialNum;
AgentResumePacket resume = new AgentResumePacket
{
AgentData =
{
AgentID = Client.Self.AgentID,
SessionID = Client.Self.SessionID,
SerialNum = pause.AgentData.SerialNum
}
};
Client.Network.SendPacket(resume);