corrade-vassal – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using OpenMetaverse;
5 using OpenMetaverse.Packets;
6  
7 namespace OpenMetaverse.TestClient
8 {
9 /// <summary>
10 /// Sends a packet of type GenericMessage to the simulator.
11 /// </summary>
12 public class GenericMessageCommand : Command
13 {
14 public GenericMessageCommand(TestClient testClient)
15 {
16 Name = "sendgeneric";
17 Description = "send a generic UDP message to the simulator.";
18 Category = CommandCategory.Other;
19 }
20  
21 public override string Execute(string[] args, UUID fromAgentID)
22 {
23 UUID target;
24  
25 if (args.Length < 1)
26 return "Usage: sendgeneric method_name [value1 value2 ...]";
27  
28 string methodName = args[0];
29  
30 GenericMessagePacket gmp = new GenericMessagePacket();
31  
32 gmp.AgentData.AgentID = Client.Self.AgentID;
33 gmp.AgentData.SessionID = Client.Self.SessionID;
34 gmp.AgentData.TransactionID = UUID.Zero;
35  
36 gmp.MethodData.Method = Utils.StringToBytes(methodName);
37 gmp.MethodData.Invoice = UUID.Zero;
38  
39 gmp.ParamList = new GenericMessagePacket.ParamListBlock[args.Length - 1];
40  
41 StringBuilder sb = new StringBuilder();
42  
43 for (int i = 1; i < args.Length; i++)
44 {
45 GenericMessagePacket.ParamListBlock paramBlock = new GenericMessagePacket.ParamListBlock();
46 paramBlock.Parameter = Utils.StringToBytes(args[i]);
47 gmp.ParamList[i - 1] = paramBlock;
48 sb.AppendFormat(" {0}", args[i]);
49 }
50  
51 Client.Network.SendPacket(gmp);
52  
53 return string.Format("Sent generic message with method {0}, params{1}", methodName, sb);
54 }
55 }
56 }