corrade-vassal – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1  
2 using System;
3 using System.Collections.Generic;
4 using System.Threading;
5 using OpenMetaverse;
6 using OpenMetaverse.Packets;
7  
8 namespace OpenMetaverse.TestClient
9 {
10 public class VoiceAccountCommand : Command
11 {
12 private AutoResetEvent ProvisionEvent = new AutoResetEvent(false);
13 private string VoiceAccount = null;
14 private string VoicePassword = null;
15  
16 public VoiceAccountCommand(TestClient testClient)
17 {
18 Name = "voiceaccount";
19 Description = "obtain voice account info. Usage: voiceaccount";
20 Category = CommandCategory.Voice;
21  
22 Client = testClient;
23 }
24  
25 private bool registered = false;
26  
27 private bool IsVoiceManagerRunning()
28 {
29 if (null == Client.VoiceManager) return false;
30  
31 if (!registered)
32 {
33 Client.VoiceManager.OnProvisionAccount += Voice_OnProvisionAccount;
34 registered = true;
35 }
36 return true;
37 }
38  
39 public override string Execute(string[] args, UUID fromAgentID)
40 {
41 if (!IsVoiceManagerRunning())
42 return String.Format("VoiceManager not running for {0}", Client.Self.Name);
43  
44 if (!Client.VoiceManager.RequestProvisionAccount())
45 {
46 return "RequestProvisionAccount failed. Not available for the current grid?";
47 }
48 ProvisionEvent.WaitOne(30 * 1000, false);
49  
50 if (String.IsNullOrEmpty(VoiceAccount) && String.IsNullOrEmpty(VoicePassword))
51 {
52 return String.Format("Voice account information lookup for {0} failed.", Client.Self.Name);
53 }
54  
55 return String.Format("Voice Account for {0}: user \"{1}\", password \"{2}\"",
56 Client.Self.Name, VoiceAccount, VoicePassword);
57 }
58  
59 void Voice_OnProvisionAccount(string username, string password)
60 {
61 VoiceAccount = username;
62 VoicePassword = password;
63  
64 ProvisionEvent.Set();
65 }
66 }
67 }