Example #1
0
        /// <summary>
        /// 
        /// </summary>
        public TestClient(ClientManager manager)
        {
			ClientManager = manager;

            updateTimer = new System.Timers.Timer(500);
            updateTimer.Elapsed += new System.Timers.ElapsedEventHandler(updateTimer_Elapsed);

            RegisterAllCommands(Assembly.GetExecutingAssembly());

            Settings.LOG_LEVEL = Helpers.LogLevel.Debug;
            Settings.LOG_RESENDS = false;
            Settings.STORE_LAND_PATCHES = true;
            Settings.ALWAYS_DECODE_OBJECTS = true;
            Settings.ALWAYS_REQUEST_OBJECTS = true;
            Settings.SEND_AGENT_UPDATES = true;
            Settings.USE_TEXTURE_CACHE = true;

            Network.RegisterCallback(PacketType.AgentDataUpdate, new NetworkManager.PacketCallback(AgentDataUpdateHandler));
            Network.OnLogin += new NetworkManager.LoginCallback(LoginHandler);
            Self.OnInstantMessage += new AgentManager.InstantMessageCallback(Self_OnInstantMessage);
            Groups.OnGroupMembers += new GroupManager.GroupMembersCallback(GroupMembersHandler);
            Inventory.OnObjectOffered += new InventoryManager.ObjectOfferedCallback(Inventory_OnInventoryObjectReceived);

            Network.RegisterCallback(PacketType.AvatarAppearance, new NetworkManager.PacketCallback(AvatarAppearanceHandler));
            Network.RegisterCallback(PacketType.AlertMessage, new NetworkManager.PacketCallback(AlertMessageHandler));

            VoiceManager = new VoiceManager(this);

            updateTimer.Start();
        }
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;
            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 <[email protected]>");
                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: " + VoiceAccount + 
                                  ", Password: " + VoicePassword);


                Console.WriteLine("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 #3
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 <[email protected]>"))
                {
                    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: " + VoiceAccount + ", Password: " + VoicePassword);
                                Console.WriteLine("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();
        }