using System;
using System.Threading;
using System.Threading.Tasks;
using EmbedIO.Sessions;
namespace EmbedIO
{
///
/// Represents a web server.
/// The basic usage of a web server is as follows:
///
/// - add modules to the Modules collection;
/// - set a if needed;
/// - call to respond to incoming requests.
///
///
public interface IWebServer : IWebModuleContainer, IMimeTypeCustomizer
{
///
/// Occurs when the property changes.
///
event WebServerStateChangedEventHandler StateChanged;
///
/// Gets or sets a callback that is called every time an unhandled exception
/// occurs during the processing of a request.
/// This property can never be .
/// If it is still
///
///
ExceptionHandlerCallback OnUnhandledException { get; set; }
///
/// Gets or sets a callback that is called every time a HTTP exception
/// is thrown during the processing of a request.
/// This property can never be .
///
///
HttpExceptionHandlerCallback OnHttpException { get; set; }
///
/// Gets or sets the registered session ID manager, if any.
/// A session ID manager is an implementation of .
/// Note that this property can only be set before starting the web server.
///
///
/// The session manager, or if no session manager is present.
///
/// This property is being set and the web server has already been started.
ISessionManager? SessionManager { get; set; }
///
/// Gets the state of the web server.
///
/// The state.
///
WebServerState State { get; }
///
/// Starts the listener and the registered modules.
///
/// The cancellation token; when cancelled, the server cancels all pending requests and stops.
///
/// Returns the task that the HTTP listener is running inside of, so that it can be waited upon after it's been canceled.
///
Task RunAsync(CancellationToken cancellationToken = default);
}
}