Example #1
0
        static void Main(string[] args)
        {
            if (args.Length < 3)
            {
                Console.WriteLine("Usage: VoiceTest.exe [firstname] [lastname] [password]");
                return;
            }

            string firstName = args[0];
            string lastName = args[1];
            string password = args[2];
            

            SecondLife client = new SecondLife();
            client.Settings.MULTIPLE_SIMS = false;
            Settings.LOG_LEVEL = Helpers.LogLevel.None;
            client.Settings.LOG_RESENDS = false;
            client.Settings.STORE_LAND_PATCHES = true;
            client.Settings.ALWAYS_DECODE_OBJECTS = true;
            client.Settings.ALWAYS_REQUEST_OBJECTS = true;
            client.Settings.SEND_AGENT_UPDATES = true;

            string loginURI = client.Settings.LOGIN_SERVER;
            if (4 == args.Length) {
                loginURI = args[3];
            }

            VoiceManager voice = new VoiceManager(client);
            voice.OnProvisionAccount += voice_OnProvisionAccount;
            voice.OnParcelVoiceInfo += voice_OnParcelVoiceInfo;

            client.Network.OnEventQueueRunning += client_OnEventQueueRunning;

            try {
                if (!voice.ConnectToDaemon()) throw new VoiceException("Failed to connect to the voice daemon");

                List<string> captureDevices = voice.CaptureDevices();

                Console.WriteLine("Capture Devices:");
                for (int i = 0; i < captureDevices.Count; i++)
                    Console.WriteLine(String.Format("{0}. \"{1}\"", i, captureDevices[i]));
                Console.WriteLine();

                List<string> renderDevices = voice.RenderDevices();

                Console.WriteLine("Render Devices:");
                for (int i = 0; i < renderDevices.Count; i++)
                    Console.WriteLine(String.Format("{0}. \"{1}\"", i, renderDevices[i]));
                Console.WriteLine();


                // Login to SL
                Console.WriteLine("Logging in to Second Life as " + firstName + " " + lastName + "...");
                LoginParams loginParams = 
                    client.Network.DefaultLoginParams(firstName, lastName, password, "Voice Test", 
                                                      "Metaverse Industries LLC <*****@*****.**>");
                loginParams.URI = loginURI;
                if (!client.Network.Login(loginParams))
                    throw new VoiceException("Login to SL failed: " + client.Network.LoginMessage);
                Console.WriteLine("Logged in: " + client.Network.LoginMessage);


                Console.WriteLine("Creating voice connector...");
                int status;
                string connectorHandle = voice.CreateConnector(out status);
                if (String.IsNullOrEmpty(connectorHandle)) 
                    throw new VoiceException("Failed to create a voice connector, error code: " + status, true);
                Console.WriteLine("Voice connector handle: " + connectorHandle);


                Console.WriteLine("Waiting for OnEventQueueRunning");
                if (!EventQueueRunningEvent.WaitOne(45 * 1000, false)) 
                    throw new VoiceException("EventQueueRunning event did not occur", true);
                Console.WriteLine("EventQueue running");


                Console.WriteLine("Asking the current simulator to create a provisional account...");
                if (!voice.RequestProvisionAccount()) 
                    throw new VoiceException("Failed to request a provisional account", true); 
                if (!ProvisionEvent.WaitOne(120 * 1000, false)) 
                    throw new VoiceException("Failed to create a provisional account", true);
                Console.WriteLine("Provisional account created. Username: "******", Password: "******"Logging in to voice server " + voice.VoiceServer);
                string accountHandle = voice.Login(VoiceAccount, VoicePassword, connectorHandle, out status);
                if (String.IsNullOrEmpty(accountHandle)) 
                    throw new VoiceException("Login failed, error code: " + status, true);
                Console.WriteLine("Login succeeded, account handle: " + accountHandle);


                if (!voice.RequestParcelVoiceInfo()) 
                    throw new Exception("Failed to request parcel voice info");
                if (!ParcelVoiceInfoEvent.WaitOne(45 * 1000, false)) 
                    throw new VoiceException("Failed to obtain parcel info voice", true);


                Console.WriteLine("Parcel Voice Info obtained. Region name {0}, local parcel ID {1}, channel URI {2}",
                                  VoiceRegionName, VoiceLocalID, VoiceChannelURI);

                client.Network.Logout();
            }
            catch(Exception e) 
            {
                Console.WriteLine(e.Message);
                if (e is VoiceException && (e as VoiceException).LoggedIn) 
                {
                    client.Network.Logout();
                }
                
            }
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
Example #2
0
        static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                Console.WriteLine("Usage: VoiceTest.exe [firstname] [lastname] [password]");
                return;
            }

            string firstName = args[0];
            string lastName = args[1];
            string password = args[2];

            SecondLife client = new SecondLife();
            client.Settings.MULTIPLE_SIMS = false;
            //client.OnLogMessage += new SecondLife.LogCallback(client_OnLogMessage);

            VoiceManager voice = new VoiceManager(client);
            voice.OnProvisionAccount += new VoiceManager.ProvisionAccountCallback(voice_OnProvisionAccount);

            if (voice.ConnectToDaemon())
            {
                List<string> captureDevices = voice.CaptureDevices();

                Console.WriteLine("Capture Devices:");
                for (int i = 0; i < captureDevices.Count; i++)
                    Console.WriteLine(String.Format("{0}. \"{1}\"", i, captureDevices[i]));
                Console.WriteLine();

                List<string> renderDevices = voice.RenderDevices();

                Console.WriteLine("Render Devices:");
                for (int i = 0; i < renderDevices.Count; i++)
                    Console.WriteLine(String.Format("{0}. \"{1}\"", i, renderDevices[i]));
                Console.WriteLine();

                Console.WriteLine("Logging in to Second Life as " + firstName + " " + lastName + "...");

                // Login to SL
                if (client.Network.Login(firstName, lastName, password, "Voice Test", "Metaverse Industries LLC <*****@*****.**>"))
                {
                    Console.WriteLine("Creating voice connector...");

                    int status;
                    string connectorHandle = voice.CreateConnector(out status);

                    if (connectorHandle != String.Empty)
                    {
                        Console.WriteLine("Voice connector handle: " + connectorHandle);

                        // Wait for the simulator capabilities to show up
                        // FIXME: Use client.Network.OnEventQueueRunning to continue here

                        Console.WriteLine("Asking the current simulator to create a provisional account...");

                        if (voice.RequestProvisionAccount())
                        {
                            if (ProvisionEvent.WaitOne(45 * 1000, false))
                            {
                                Console.WriteLine("Provisional account created. Username: "******", Password: "******"Logging in to voice server " + voice.VoiceServer);

                                string accountHandle = voice.Login(VoiceAccount, VoicePassword, connectorHandle, out status);

                                if (accountHandle != String.Empty)
                                {
                                    Console.WriteLine("Login succeeded, account handle: " + accountHandle);
                                }
                                else
                                {
                                    Console.WriteLine("Login failed, error code: " + status);
                                    client.Network.Logout();
                                }
                            }
                            else
                            {
                                Console.WriteLine("Failed to create a provisional account");
                                client.Network.Logout();
                            }
                        }
                        else
                        {
                            Console.WriteLine("Failed to request a provisional account");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Failed to create a voice connector, error code: " + status);
                        client.Network.Logout();
                    }
                }
                else
                {
                    Console.WriteLine("Login to SL failed: " + client.Network.LoginMessage);
                }
            }
            else
            {
                Console.WriteLine("Failed to connect to the voice daemon");
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }