From e93869c7a785a4f375685ffa33c913033ed1c85a Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 21 Jun 2007 17:08:21 +0000 Subject: * Importing Ming's mass test client --- .../Commands/Communication/EchoMasterCommand.cs | 42 +++++++++++++ .../Commands/Communication/IMCommand.cs | 71 ++++++++++++++++++++++ .../Commands/Communication/SayCommand.cs | 44 ++++++++++++++ .../Commands/Communication/ShoutCommand.cs | 49 +++++++++++++++ .../Commands/Communication/TtsCommand.cs | 51 ++++++++++++++++ .../Commands/Communication/WhisperCommand.cs | 49 +++++++++++++++ 6 files changed, 306 insertions(+) create mode 100644 tools/mass test client/Commands/Communication/EchoMasterCommand.cs create mode 100644 tools/mass test client/Commands/Communication/IMCommand.cs create mode 100644 tools/mass test client/Commands/Communication/SayCommand.cs create mode 100644 tools/mass test client/Commands/Communication/ShoutCommand.cs create mode 100644 tools/mass test client/Commands/Communication/TtsCommand.cs create mode 100644 tools/mass test client/Commands/Communication/WhisperCommand.cs (limited to 'tools/mass test client/Commands/Communication') diff --git a/tools/mass test client/Commands/Communication/EchoMasterCommand.cs b/tools/mass test client/Commands/Communication/EchoMasterCommand.cs new file mode 100644 index 0000000..a7c3d3f --- /dev/null +++ b/tools/mass test client/Commands/Communication/EchoMasterCommand.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class EchoMasterCommand: Command + { + public EchoMasterCommand(TestClient testClient) + { + Name = "echoMaster"; + Description = "Repeat everything that master says."; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + if (!Active) + { + Active = true; + Client.Self.OnChat += new MainAvatar.ChatCallback(Self_OnChat); + return "Echoing is now on."; + } + else + { + Active = false; + Client.Self.OnChat -= new MainAvatar.ChatCallback(Self_OnChat); + return "Echoing is now off."; + } + } + + void Self_OnChat(string message, MainAvatar.ChatAudibleLevel audible, MainAvatar.ChatType type, + MainAvatar.ChatSourceType sourcetype, string fromName, LLUUID id, LLUUID ownerid, LLVector3 position) + { + if (message.Length > 0 && Client.MasterKey == id) + { + Client.Self.Chat(message, 0, MainAvatar.ChatType.Normal); + } + } + } +} diff --git a/tools/mass test client/Commands/Communication/IMCommand.cs b/tools/mass test client/Commands/Communication/IMCommand.cs new file mode 100644 index 0000000..d847291 --- /dev/null +++ b/tools/mass test client/Commands/Communication/IMCommand.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class ImCommand : Command + { + string ToAvatarName = String.Empty; + ManualResetEvent NameSearchEvent = new ManualResetEvent(false); + Dictionary Name2Key = new Dictionary(); + + public ImCommand(TestClient testClient) + { + testClient.Avatars.OnAvatarNameSearch += new AvatarManager.AvatarNameSearchCallback(Avatars_OnAvatarNameSearch); + + Name = "im"; + Description = "Instant message someone. Usage: im [firstname] [lastname] [message]"; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + if (args.Length < 3) + return "Usage: im [firstname] [lastname] [message]"; + + ToAvatarName = args[0] + " " + args[1]; + + // Build the message + string message = String.Empty; + for (int ct = 2; ct < args.Length; ct++) + message += args[ct] + " "; + message = message.TrimEnd(); + if (message.Length > 1023) message = message.Remove(1023); + + if (!Name2Key.ContainsKey(ToAvatarName.ToLower())) + { + // Send the Query + Client.Avatars.RequestAvatarNameSearch(ToAvatarName, LLUUID.Random()); + + NameSearchEvent.WaitOne(6000, false); + } + + if (Name2Key.ContainsKey(ToAvatarName.ToLower())) + { + LLUUID id = Name2Key[ToAvatarName.ToLower()]; + + Client.Self.InstantMessage(id, message, id); + return "Instant Messaged " + id.ToStringHyphenated() + " with message: " + message; + } + else + { + return "Name lookup for " + ToAvatarName + " failed"; + } + } + + void Avatars_OnAvatarNameSearch(LLUUID queryID, Dictionary avatars) + { + foreach (KeyValuePair kvp in avatars) + { + if (kvp.Value.ToLower() == ToAvatarName.ToLower()) + { + Name2Key[ToAvatarName.ToLower()] = kvp.Key; + NameSearchEvent.Set(); + return; + } + } + } + } +} diff --git a/tools/mass test client/Commands/Communication/SayCommand.cs b/tools/mass test client/Commands/Communication/SayCommand.cs new file mode 100644 index 0000000..2ab9db4 --- /dev/null +++ b/tools/mass test client/Commands/Communication/SayCommand.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace libsecondlife.TestClient +{ + public class SayCommand: Command + { + public SayCommand(TestClient testClient) + { + Name = "say"; + Description = "Say something. (usage: say (optional channel) whatever)"; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + int channel = 0; + int startIndex = 0; + + if (args.Length < 1) + { + return "usage: say (optional channel) whatever"; + } + else if (args.Length > 1) + { + if (Int32.TryParse(args[0], out channel)) + startIndex = 1; + } + + StringBuilder message = new StringBuilder(); + + for (int i = startIndex; i < args.Length; i++) + { + message.Append(args[i]); + if (i != args.Length - 1) message.Append(" "); + } + + Client.Self.Chat(message.ToString(), channel, MainAvatar.ChatType.Normal); + + return "Said " + message.ToString(); + } + } +} diff --git a/tools/mass test client/Commands/Communication/ShoutCommand.cs b/tools/mass test client/Commands/Communication/ShoutCommand.cs new file mode 100644 index 0000000..3533e3d --- /dev/null +++ b/tools/mass test client/Commands/Communication/ShoutCommand.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class ShoutCommand : Command + { + public ShoutCommand(TestClient testClient) + { + Name = "shout"; + Description = "Shout something."; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + int channel = 0; + int startIndex = 0; + string message = String.Empty; + if (args.Length < 1) + { + return "usage: shout (optional channel) whatever"; + } + else if (args.Length > 1) + { + try + { + channel = Convert.ToInt32(args[0]); + startIndex = 1; + } + catch (FormatException) + { + channel = 0; + } + } + + for (int i = startIndex; i < args.Length; i++) + { + message += args[i] + " "; + } + + Client.Self.Chat(message, channel, MainAvatar.ChatType.Shout); + + return "Shouted " + message; + } + } +} diff --git a/tools/mass test client/Commands/Communication/TtsCommand.cs b/tools/mass test client/Commands/Communication/TtsCommand.cs new file mode 100644 index 0000000..52b7a39 --- /dev/null +++ b/tools/mass test client/Commands/Communication/TtsCommand.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Speech.Synthesis; +using libsecondlife; +using libsecondlife.Packets; +using libsecondlife.AssetSystem; + + +// Since this requires .Net 3.0 I've left it out of the project by default. +// To use this: include it in the project and add a reference to the System.Speech.dll + +namespace libsecondlife.TestClient +{ + public class TtsCommand : Command + { + SpeechSynthesizer _speechSynthesizer; + + public TtsCommand(TestClient testClient) + { + Name = "tts"; + Description = "Text To Speech. When activated, client will echo all recieved chat messages out thru the computer's speakers."; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + if (!Active) + { + if (_speechSynthesizer == null) + _speechSynthesizer = new SpeechSynthesizer(); + Active = true; + Client.Self.OnChat += new MainAvatar.ChatCallback(Self_OnChat); + return "TTS is now on."; + } + else + { + Active = false; + Client.Self.OnChat -= new MainAvatar.ChatCallback(Self_OnChat); + return "TTS is now off."; + } + } + + void Self_OnChat(string message, byte audible, byte type, byte sourcetype, string fromName, LLUUID id, LLUUID ownerid, LLVector3 position) + { + if (message.Length > 0) + { + _speechSynthesizer.SpeakAsync(message); + } + } + } +} \ No newline at end of file diff --git a/tools/mass test client/Commands/Communication/WhisperCommand.cs b/tools/mass test client/Commands/Communication/WhisperCommand.cs new file mode 100644 index 0000000..4bfda33 --- /dev/null +++ b/tools/mass test client/Commands/Communication/WhisperCommand.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class WhisperCommand : Command + { + public WhisperCommand(TestClient testClient) + { + Name = "whisper"; + Description = "Whisper something."; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + int channel = 0; + int startIndex = 0; + string message = String.Empty; + if (args.Length < 1) + { + return "usage: whisper (optional channel) whatever"; + } + else if (args.Length > 1) + { + try + { + channel = Convert.ToInt32(args[0]); + startIndex = 1; + } + catch (FormatException) + { + channel = 0; + } + } + + for (int i = startIndex; i < args.Length; i++) + { + message += args[i] + " "; + } + + Client.Self.Chat(message, channel, MainAvatar.ChatType.Whisper); + + return "Whispered " + message; + } + } +} -- cgit v1.1