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(); } }
/// <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()); }
public void Dispose() { _listener?.Dispose(); _listener = null; }