public MqttService( IHostApplicationLifetime appLifetime, LoadPlugin loadPlugin, IOptions <MqttConfig> mqttConfig, ILogger <MqttService> logger) { var mqttFactory = new MqttFactory(); _mqttClient = mqttFactory.CreateMqttClient(); _mqttConfig = mqttConfig.Value; _loadPlugin = loadPlugin; _logger = logger; _appLifetime = appLifetime; _plugins = _loadPlugin.LoadPlugins(); }
/// <summary> /// Initializes a new instance of the <see cref="BotEngineExample"/> class. /// /// You will have to have a valid app.Config settings file, please read documentation on codeplex. /// </summary> public ServerConsole() { //ServicesManager.StartService(_commandInterpeter.TechnicalName); Console.ParseCommandLine = ProcessCommandLine; Console.Title = string.Format("Managed Bot Engine Server {0}\r\n", base.Version()); Console.BackgroundColor = ConsoleColor.DarkBlue; Console.Clear(); CrossAppDomainSingletonT <CrossAppDomainSingleton> .Instance.Shared = this; ServicesManager.OnServiceStarted += ServicesManager_OnServiceStarted; LocalBotPluginServicesManager.OnServiceStarted += LocalBotPluginServicesManager_OnServiceStarted; BotEventSlaveStarted += HandleBotEventSlaveStarted; BotEventLoggedIn += HandleBotEventLoggedIn; BotEventEntersWorld += HandleBotEventEntersWorld; Console.WriteLine(ConsoleMessageType.Information, string.Format("Managed Bot Engine Server {0}\r\nCopyright (C)2009-2010 TCPX\r\n", base.Version())); Console.WriteLine(ConsoleMessageType.Information, "Starting services"); Console.ReadLine(); _sw1.Start(); // ensure creation of remote client test account for the AwManaged.RemotingTests console application. Console.WriteLine("Connecting to your Universe"); try { Start(); } catch (Exception ex) { Console.WriteLine(ConsoleMessageType.Error, ex.Message); Console.WriteLine(ConsoleMessageType.Information, "Please check your application configuration universe connection settings."); Console.WriteLine(ConsoleMessageType.Information, "Press enter to exit."); System.Console.ReadLine(); Environment.Exit(0); } _commandInterpeter = new GenericInterpreterService <CCEnumTypeAttribute, CCEnumBindingAttribute, CCItemBindingAttribute> (Assembly.GetAssembly(GetType())) { IdentifyableTechnicalName = "Server Console interpeter" }; ServicesManager.AddService(_commandInterpeter); ServicesManager.StartService(_commandInterpeter.IdentifyableTechnicalName); // load persistent plugins. // persist thie command object if it does not exist. var q = from PersistedPlugin p in Storage.Db select p; foreach (var item in q.ToList()) { var instance = new LoadPlugin() { Name = item.Name }; instance.Interpreted = new List <ICommandGroup>(); instance.BotEngine = this; instance.Interpreted.Add(new Load()); var result = instance.ExecuteCommand(); Console.WriteLine(result.DisplayMessage); } }