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.Threading;
4 using OpenMetaverse;
5 using OpenMetaverse.Packets;
6 using System.Text;
7  
8 namespace OpenMetaverse.TestClient
9 {
10 public class MapFriendCommand : Command
11 {
12 ManualResetEvent WaitforFriend = new ManualResetEvent(false);
13  
14 public MapFriendCommand(TestClient testClient)
15 {
16 Name = "mapfriend";
17 Description = "Show a friends location. Usage: mapfriend UUID";
18 Category = CommandCategory.Friends;
19 }
20 public override string Execute(string[] args, UUID fromAgentID)
21 {
22 if (args.Length != 1)
23 return Description;
24  
25 UUID targetID;
26  
27 if (!UUID.TryParse(args[0], out targetID))
28 return Description;
29  
30 StringBuilder sb = new StringBuilder();
31  
32 EventHandler<FriendFoundReplyEventArgs> del = delegate(object sender, FriendFoundReplyEventArgs e)
33 {
34 if (!e.RegionHandle.Equals(0))
35 sb.AppendFormat("Found Friend {0} in {1} at {2}/{3}", e.AgentID, e.RegionHandle, e.Location.X, e.Location.Y);
36 else
37 sb.AppendFormat("Found Friend {0}, But they appear to be offline", e.AgentID);
38  
39 WaitforFriend.Set();
40 };
41  
42  
43  
44 Client.Friends.FriendFoundReply += del;
45 WaitforFriend.Reset();
46 Client.Friends.MapFriend(targetID);
47 if (!WaitforFriend.WaitOne(10000, false))
48 {
49 sb.AppendFormat("Timeout waiting for reply, Do you have mapping rights on {0}?", targetID);
50 }
51 Client.Friends.FriendFoundReply -= del;
52 return sb.ToString();
53 }
54 }
55 }