/// <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_ASSET_CACHE = true;

            Network.RegisterCallback(PacketType.AgentDataUpdate, AgentDataUpdateHandler);
            Network.LoginProgress += LoginHandler;
            Objects.AvatarUpdate += new EventHandler<AvatarUpdateEventArgs>(Objects_AvatarUpdate);
            Objects.TerseObjectUpdate += new EventHandler<TerseObjectUpdateEventArgs>(Objects_TerseObjectUpdate);
            Network.SimChanged += new EventHandler<SimChangedEventArgs>(Network_SimChanged);
            Self.IM += Self_IM;
            Groups.GroupMembersReply += GroupMembersHandler;
            Inventory.InventoryObjectOffered += Inventory_OnInventoryObjectReceived;

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

            VoiceManager = new VoiceManager(this);

            updateTimer.Start();
        }
Exemple #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];
            

            GridClient client = new GridClient();
            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
                Console.WriteLine("Logging into the grid as " + firstName + " " + lastName + "...");
                LoginParams loginParams = 
                    client.Network.DefaultLoginParams(firstName, lastName, password, "Voice Test", "1.0.0");
                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();
        }
Exemple #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];

            Settings.LOG_LEVEL = Helpers.LogLevel.None;

            GridClient client = new GridClient();
            client.Settings.MULTIPLE_SIMS = false;
            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;
            client.Network.OnEventQueueRunning += client_OnEventQueueRunning;

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

            try {

                // Login
                Console.WriteLine("Logging into the grid as " + firstName + " " + lastName + "...");
                LoginParams loginParams =
                    client.Network.DefaultLoginParams(firstName, lastName, password, "Voice Test", "1.0.0");
                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);

                // Create VoiceManager
                voice = new VoiceManager(client);
                voice.OnParticipantProperties += new VoiceManager.ParticipantPropertiesCallback(voice_OnParticipantProperties);
                voice.OnProvisionAccount += voice_OnProvisionAccount;
                voice.OnParcelVoiceInfo += voice_OnParcelVoiceInfo;
                voice.OnSessionTerminated += new VoiceManager.SessionCreatedCallback(voice_OnSessionTerminated);
                voice.OnAccountLogout += new VoiceManager.BasicActionCallback(voice_OnAccountLogout);
                voice.OnConnectorInitiateShutdown += new VoiceManager.BasicActionCallback(voice_OnConnectorInitiateShutdown);
                voice.BlockingTimeout = 5 * 1000;
                voice.OnNewSession += new VoiceManager.NewSessionCallback(voice_OnNewSession);

                //voice.VoiceAccountFromUUID(UUID.Parse("709bd3d8-b28f-f22e-01fc-6d3d1c1f9293"));
                //UUID v = voice.UUIDFromVoiceAccount("xcJvT2LKP8i4B_G09HB-Skw==");

                StartDaemon();

                StopDaemon();

                Console.WriteLine("Exit? Press 'Y' (If another key was pressed, continue.)");
                string res = System.Console.ReadLine();

                if (res != "y")
                {
                    StartDaemon();

                    StopDaemon();
                }

                Console.WriteLine("Request logout.");
                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();
        }
Exemple #4
0
        /// <summary>
        /// 
        /// </summary>
        public BotClient(ClientManager manager, GridClient g)
        {
            OpenMetaverse.Utils.InternStrings = true;
            LoginRetries = LoginRetriesFresh;
            ClientManager = manager;
            ClientManager.LastRefBotClient = this;
            _gridClient = g;
            manager.AddBotClient(this);
            NeedRunOnLogin = true;
            //manager.LastRefBotClient = this;

            Settings.USE_INTERPOLATION_TIMER = false;
            Settings.LOG_LEVEL = Helpers.LogLevel.None;

            //   Settings.LOG_RESENDS = false;
            //   Settings.ALWAYS_DECODE_OBJECTS = true;
            //   Settings.ALWAYS_REQUEST_OBJECTS = true;
            //   Settings.SEND_AGENT_UPDATES = true;
            ////   Settings.SYNC_PACKETCALLBACKS = true;
            //   Settings.OBJECT_TRACKING = true;
            //   //Settings.STORE_LAND_PATCHES = true;
            //   //Settings.USE_TEXTURE_CACHE = true;
            //   //Settings.PARCEL_TRACKING = true;
            //   //Settings.FETCH_MISSING_INVENTORY = true;
            //   // Optimize the throttle
            //   Throttle.Wind = 0;
            //   Throttle.Cloud = 0;
            //   Throttle.Land = 1000000;
            //   Throttle.Task = 1000000;
            ////Throttle.Total = 250000;
            // Settings.CAPS_TIMEOUT = 6 * 1000;
            Settings.RESEND_TIMEOUT = 20 * 1000;
            Settings.MAX_RESEND_COUNT = 10;
            Settings.LOGIN_TIMEOUT = 120 * 1000;
            //Settings.LOGOUT_TIMEOUT = 120 * 1000;
            //Settings.SIMULATOR_TIMEOUT = int.MaxValue;
            //Settings.SEND_PINGS = true;
            Settings.SEND_AGENT_APPEARANCE = true;
            Settings.LOG_DISKCACHE = false;
            //Settings.USE_LLSD_LOGIN = true;
            ////Settings.MULTIPLE_SIMS = false;

            VoiceManager = new VoiceManager(gridClient);
            //manager.AddBotClientToTextForm(this);

            botPipeline = new SimEventMulticastPipeline(this);
            OneAtATimeQueue = new TaskQueueHandler(this, new NamedPrefixThing("OneAtATimeQueue", GetName), new TimeSpan(0, 0, 0, 0, 10),
                                                   true, true);
            AddTaskQueue("OneAtATimeQueue", OneAtATimeQueue);

            SetSecurityLevel(OWNERLEVEL, null, BotPermissions.Owner);
            ClientManager.PostAutoExecEnqueue(OneAtATimeQueue.Start);

            botPipeline.AddSubscriber(new SimEventTextSubscriber(SimEventWriteLine, this));
            // SingleInstance = this;
            ///this = this;// new GridClient();


            Settings.ALWAYS_DECODE_OBJECTS = true;
            Settings.ALWAYS_REQUEST_OBJECTS = true;
            Settings.OBJECT_TRACKING = true;
            Settings.AVATAR_TRACKING = true;
            Settings.STORE_LAND_PATCHES = true;
            Settings.CACHE_PRIMITIVES = true;
            Settings.POOL_PARCEL_DATA = true;


            //  Manager = Inventory;
            //Inventory = Manager.Store;

            // config = new Configuration();
            // config.loadConfig();
            /// Settings.LOGIN_SERVER = config.simURL;
            // Opensim recommends 250k total

            //Settings.ENABLE_CAPS = true;
            Self.Movement.Camera.Far = 512f;
            //Settings.LOG_ALL_CAPS_ERRORS = true;
            //Settings.FETCH_MISSING_INVENTORY = true;
            //Settings.SEND_AGENT_THROTTLE = false;

            //muteList = new List<string>();

            Plugins = new Dictionary<string, Cogbot.Listener>();
            //registrationTypes["avatars"] = new Cogbot.Avatars(this);
            //registrationTypes["chat"] = new Cogbot.Chat(this);
            WorldSystem = new Cogbot.WorldObjects(this);
            //registrationTypes["teleport"] = new Cogbot.Teleport(this);
            //registrationTypes["whisper"] = new Cogbot.Whisper(this);
            //ObjectSystem = new Cogbot.Objects(this);
            //registrationTypes["bump"] = new Cogbot.Bump(this);
            //registrationTypes["sound"] = new Cogbot.Sound(this);
            //registrationTypes["sound"] = new Cogbot.Objects(this);
            var gc = gridClient;
            //_gridClient = null;
            Commands = new SortedDictionary<string, CommandInstance>();
			RegisterCommand("login", new Login(this));
			RegisterCommand("logout", new Logout(this));
			RegisterCommand("stop", new StopCommand(this));
			RegisterCommand("teleport", new Teleport(this));
			var desc = newCommandInfo(new Describe(this));
			Commands["describe"] = desc;
			Commands["look"] = desc;
            RegisterCommand("say", new Cogbot.Actions.Communication.SayCommand(this));
			RegisterCommand("help", new Cogbot.Actions.System.Help(this));
            RegisterCommand("setmaster", new Cogbot.Actions.System.SetMasterKeyCommand(this));
            RegisterCommand("setmasterkey", new Cogbot.Actions.System.SetMasterKeyCommand(this));
			RegisterCommand("sit", new Sit(this));
			RegisterCommand("stand", new StandCommand(this));
			RegisterCommand("jump", new JumpCommand(this));
			RegisterCommand("crouch", new CrouchCommand(this));
			RegisterCommand("mute", new MuteCommand(this));
			RegisterCommand("unmute", new UnmuteCommand(this));
            RegisterCommand("move", new MoveToCommand(this)); 
            RegisterCommand("forward", new MoveToCommand(this));
			RegisterCommand("use", new Use(this));
			RegisterCommand("eval", new Eval(this));
			RegisterCommand("wear", new ReplaceOutfitCommand(this));
            RegisterCommand("task", new ThreadCommand(this));
            RegisterCommand("thread", new ThreadCommand(this));
            

            Commands["locate"] = Commands["location"] = Commands["where"] = newCommandInfo(new Actions.Movement.LocationCommand(this));
            var follow = newCommandInfo(new Follow(this));
            Commands["follow"] = follow;
            //Commands["simexport"] = new Cogbot.Actions.SimExport.ExportCommand(this);
            Commands["stop following"] = follow;
            Commands["stop-following"] = follow;

            // ensure all commands are registered when this constructor completes
            foreach (Type type in GetType().Assembly.GetTypes())
            {
                RegisterType(type);
            }
            
            _gridClient = gc;

            XmlInterp = new XmlScriptInterpreter(this);
            XmlInterp.BotClient = this;
            if (false)
                ClientManager.PostAutoExecEnqueue(LoadTaskInterpreter);

            // Start the server
            lock (ClientManager.config)
            {
                int poff = ClientManager.config.GetValue("tcpPortOffset", 10);
                thisTcpPort = ClientManager.nextTcpPort;
                ClientManager.nextTcpPort += poff;
                ClientManager.PostAutoExecEnqueue(() =>
                {
                    Utilities.BotTcpServer UtilitiesTcpServer = new Utilities.BotTcpServer(thisTcpPort, this);
                    UtilitiesTcpServer.ServerPortIncr = poff;
                    UtilitiesTcpServer.startSocketListener();
                    ClientManager.nextTcpPort = UtilitiesTcpServer.ServerPort + UtilitiesTcpServer.ServerPortIncr;
                    this.OnDispose += ((SimEventSubscriber)UtilitiesTcpServer).Dispose;
                });
            }

            Network.RegisterCallback(PacketType.AgentDataUpdate, AgentDataUpdateHandler);
            Network.RegisterCallback(PacketType.AlertMessage, AlertMessageHandler);
            Network.RegisterCallback(PacketType.AvatarAppearance, AvatarAppearanceHandler);

            //Move to effects Appearance.OnAppearanceUpdated += new AppearanceManager.AppearanceUpdatedCallback(Appearance_OnAppearanceUpdated);

            Inventory.InventoryObjectOffered += Inventory_OnInventoryObjectReceived;
            Groups.GroupMembersReply += new EventHandler<GroupMembersReplyEventArgs>(GroupMembersHandler);
            Logger.OnLogMessage += new Logger.LogCallback(client_OnLogMessage);
            Network.EventQueueRunning += Network_OnEventQueueRunning;
            Network.LoginProgress += Network_OnLogin;
            Network.LoggedOut += Network_OnLogoutReply;
            Network.SimConnected += Network_OnSimConnected;
            Network.SimDisconnected += Network_OnSimDisconnected;
            //Network.OnConnected += Network_OnConnected;
            Network.Disconnected += Network_OnDisconnected;
            Self.IM += Self_OnInstantMessage;
            //Self.OnScriptDialog += new AgentManager.ScriptDialogCallback(Self_OnScriptDialog);
            //Self.OnScriptQuestion += new AgentManager.ScriptQuestionCallback(Self_OnScriptQuestion);
            Self.TeleportProgress += Self_OnTeleport;
            Self.ChatFromSimulator += Self_OnChat;
            var callback = new EventHandler<CurrentGroupsEventArgs>(Groups_OnCurrentGroups);
            Groups.CurrentGroups += callback;

            BotInventory = new BotInventoryEval(this);
            ClientManager.PostAutoExecEnqueue(() =>
            {
                if (UseLispEventProducer)
                {
                    lispEventProducer = new LispEventProducer(this, LispTaskInterperter);
                }
            });
            ClientManager.PostAutoExecEnqueue(ClientManager.EnsureREPLNotPaused);

        }
Exemple #5
-44
        /// <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_ASSET_CACHE = true;

            Network.RegisterCallback(PacketType.AgentDataUpdate, new NetworkManager.PacketCallback(AgentDataUpdateHandler));
            Network.OnLogin += new NetworkManager.LoginCallback(LoginHandler);
            Self.IM += Self_IM;
            Groups.GroupMembersReply += 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();
        }