/// <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); }
public String taskInterpreterType = "DotLispInterpreter";// DotLispInterpreter,CycInterpreter or ABCLInterpreter public ClientManager() { lock (SingleInstanceLock) { if (_si != null) { Exception e = new Exception("Only one instance of Client Manafger please!!"); GlobalWriteLine("" + e); throw e; } SingleInstance = this; } if (!ClientManager.SingleInstance.ProcessCommandArgs()) { ConsoleApp.Usage(); } DLRConsole.AddOutput(new OutputDelegateWriter(VeryRealWriteLine)); var col = DLRConsole.TransparentCallers; lock (col) { col.Add(typeof(BotClient)); col.Add(typeof(ClientManager)); col.Add(typeof(SimEventMulticastPipeline)); col.Add(typeof(Cogbot.SimEventTextSubscriber)); col.Add(typeof(DotLisp.CLSMember)); } OneAtATimeQueue = new TaskQueueHandler(null, "ClientManager.OneAtATime", new TimeSpan(0, 0, 0, 0, 10), true, false); PostAutoExec = new TaskQueueHandler(null, "ClientManager.PostAutoExec", new TimeSpan(0, 0, 0, 0, 10), false, false); LoadConfigFile(ClientManagerConfig.arguments.GetValue("botconfig", "botconfig.xml")); foreach (var arg in ClientManagerConfig.arguments.ParamMap) { string value; if (ClientManagerConfig.arguments.TryGetValue(arg.Key, out value)) { config[arg.Key] = value; } } DefaultAccount.LoadFromConfig(config); nextTcpPort = config.GetValue("tcpPort", 5555); if (clientManagerHttpServer == null) { clientManagerHttpServer = MushDLR223.Utilities.HttpServerUtil.CreateHttpServer(this, config.GetValue("httpd",5580), "first_robot"); } groupActions = new SortedDictionary<string, Cogbot.Actions.CommandInfo>(); registrationTypes = new List<Type>(); RegisterAssembly(Assembly.GetExecutingAssembly()); RegisterAssembly(GetType().Assembly); RegisterAssembly(typeof(DLRConsole).Assembly); RegisterAssembly(typeof(PathSystem3D.Navigation.SimPathStore).Assembly); }
public void StartPlugin0(RadegastInstance inst) { RadegastInstance = inst; Control.CheckForIllegalCrossThreadCalls = false; AddRadegastEvents(); CogbotContextMenuListener = new CogbotContextMenuListener(); CogbotNoticeuListener = new CogbotNotificationListener(); if (ClientManagerConfig.UsingRadegastFromCogbot) { // just unregister events for now inst.Netcom.Dispose(); clientManager = ClientManager.SingleInstance ?? new ClientManager(); // _theBot = clientManager.LastBotClient; } else { if (!plugInitCalledEver) { CogbotGUI.GlobalRadegastInstance = inst; } ClientManagerConfig.UsingCogbotFromRadegast = true; clientManager = ClientManager.SingleInstance ?? new ClientManager(); } BotClient bc = clientManager.EnsureBotByGridClient(inst.Client); bc.TheRadegastInstance = inst; _theBot = bc; cogbotRadegastInterpreter = new CogbotRadegastInterpreter(this); RadegastInstance.CommandsManager.LoadInterpreter(cogbotRadegastInterpreter); _commandContextAction = new CommandContextAction(inst, this); _commandContextAction.ScanCogbotMenu(); inst.TabConsole.RegisterContextAction(_commandContextAction); _aspectContextAction = new AspectContextAction(inst, this); inst.TabConsole.RegisterContextAction(_aspectContextAction); _simUsageContextAction = new SimUsageContextAction(inst, this); inst.TabConsole.RegisterContextAction(_simUsageContextAction); //if (ClientManager.UsingRadgastFromCogbot) return; inst.Client.Settings.MULTIPLE_SIMS = true; clientManager.outputDelegate = System.Console.Out.WriteLine; GUIInvoke(() => SetupRadegastGUI(inst)); DLRConsole.SafelyRun(() => clientManager.ProcessCommandArgs()); chatConsole.StartWriter(); if (!bc.IsLoggedInAndReady) { TheBot.InvokeNext("Re-enable login button", () => { TheBot.DebugWriteLine("SetLoginButton = r-enabled"); SetLoginButton(OldLoginText, true); }); } if (plugInitCalledEver) { return; } plugInitCalledEver = true; if (ClientManagerConfig.StartLispThreadAtPluginInit) { RunClientManagerStartupLisp(); } }