Example #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,
                };
            }
        }
        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,
                };
            }
        }
Example #3
0
        public void Dispose()
        {
            Display?.Dispose();
            Display = null;

            webListener?.Stop();
            webListener = null;
        }
Example #4
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;
     }
 }
        public void Dispose()
        {
            Display?.Dispose();
            Display = null;

            try
            {
                webListener?.Stop();
                webListener?.Close();
            }
            catch (ObjectDisposedException) { }
            webListener = null;

#if !NET46
            // dotnet core for some reason doesn't exit the web loop
            // when calling Stop or Close.
            serverThread?.Abort();
#endif
        }