예제 #1
0
 private void OnHTTPServerError(object sender, HTTPServerEventArgs e)
 {
     Logger.LogError((e.StillAlive ? "E" : "Fatal e") + "rror during HTTP server execution: " + e.Exception.Message);
     if (!e.StillAlive)
     {
         Logger.LogVerbose("Rebooting server...");
         _listener = null;
         ResetServer();
     }
 }
예제 #2
0
        /// <summary>
        /// Resets the webhook listener, freeing any old resources.
        /// </summary>
        public void ResetServer()
        {
            try { _listener?.StopListening(); }     catch (Exception) { }

            _listener        = new HTTPServer(8080, _discordSocketClient, _databaseManager);
            _listener.Error += OnHTTPServerError;
            if (_trustedUserAgents != null)
            {
                RequestHandler.TrustedUserAgents.Clear();
                RequestHandler.TrustedUserAgents.AddRange(_trustedUserAgents);
            }
            Task.Run(() => _listener.StartListening());
        }
예제 #3
0
 public void Dispose()
 {
     _listener?.Dispose();
     _listener = null;
 }