Ejemplo n.º 1
0
        private void InitializeSubcomponents()
        {
            startWebServer = false;
            if (webData.EnableApi)
            {
                Api = new Api.WebApi();
                Injector.RegisterModule(Api);
                startWebServer = true;
            }
            if (webData.EnableWebinterface)
            {
                Display = new Interface.WebDisplay();
                Injector.RegisterModule(Display);
                startWebServer = true;
            }

            if (startWebServer)
            {
                webListener = new HttpListener
                {
                    AuthenticationSchemes = AuthenticationSchemes.Anonymous | AuthenticationSchemes.Basic,
                    Realm = WebRealm,
                    AuthenticationSchemeSelectorDelegate = AuthenticationSchemeSelector,
                };
            }
        }
Ejemplo n.º 2
0
        private void InitializeSubcomponents()
        {
            startWebServer = false;
            if (config.Interface.Enabled)
            {
                Display = new Interface.WebDisplay(config.Interface);
                Injector.RegisterModule(Display);
                startWebServer = true;
            }
            if (config.Api.Enabled || config.Interface.Enabled)
            {
                if (!config.Api.Enabled)
                {
                    Log.Warn("The api is required for the webinterface to work properly; The api is now implicitly enabled. Enable the api in the config to get rid this error message.");
                }

                Api = new Api.WebApi();
                Injector.RegisterModule(Api);
                startWebServer = true;
            }

            if (startWebServer)
            {
                webListener = new HttpListener
                {
                    AuthenticationSchemes = AuthenticationSchemes.Anonymous | AuthenticationSchemes.Basic,
                    Realm = WebRealm,
                    AuthenticationSchemeSelectorDelegate = AuthenticationSchemeSelector,
                };
            }
        }
Ejemplo n.º 3
0
 private void InitializeSubcomponents(MainBot mainBot)
 {
     startWebServer = false;
     if (webData.EnableApi)
     {
         Api            = new Api.WebApi(mainBot);
         startWebServer = true;
     }
     if (webData.EnableWebinterface)
     {
         Display        = new Interface.WebDisplay(mainBot);
         startWebServer = true;
     }
 }
Ejemplo n.º 4
0
        // TODO write server to be reload-able
        public void StartWebServer()
        {
            var startWebServer = false;

            if (config.Interface.Enabled)
            {
                var baseDir = FindWebFolder();
                if (baseDir is null)
                {
                    Log.Error("Can't find a WebInterface path to host. Try specifying the path to host in the config");
                }
                else
                {
                    startWebServer = true;
                }
            }
            if (config.Api.Enabled || config.Interface.Enabled)
            {
                if (!config.Api.Enabled)
                {
                    Log.Warn("The api is required for the webinterface to work properly; The api is now implicitly enabled. Enable the api in the config to remove this warning.");
                }

                if (!coreInjector.TryCreate <Api.WebApi>(out var api))
                {
                    throw new Exception("Could not create Api object.");
                }

                this.api       = api;
                startWebServer = true;
            }

            if (startWebServer)
            {
                StartWebServerInternal();
            }
        }