/// <summary> /// Start the server. /// </summary> public void Start() { try { // Start the server. if (_httpServer != null) { _httpServer.Start(); } } catch (Exception) { if (_httpServer != null) { _httpServer.Dispose(); } _httpServer = null; throw; } }
/// <summary> /// Initialise the server. /// </summary> private void Init() { try { // Create the http server context list. _serverList = new ConcurrentDictionary <string, HttpServerContext>(); // Create the server endpoint. Nequeo.Net.Sockets.MultiEndpointModel[] model = new Nequeo.Net.Sockets.MultiEndpointModel[] { // None secure. new Nequeo.Net.Sockets.MultiEndpointModel() { Port = Nequeo.Net.Properties.Settings.Default.HttpStaticServerListeningPort, Addresses = new System.Net.IPAddress[] { System.Net.IPAddress.IPv6Any, System.Net.IPAddress.Any } }, // Secure. new Nequeo.Net.Sockets.MultiEndpointModel() { Port = Nequeo.Net.Properties.Settings.Default.HttpStaticServerListeningPortSecure, Addresses = new System.Net.IPAddress[] { System.Net.IPAddress.IPv6Any, System.Net.IPAddress.Any } } }; // Start the server. _httpServer = new Nequeo.Net.Http2.HttpServer(model); _httpServer.Name = "Application Server"; _httpServer.OnHttpContext += HttpContext; _httpServer.Timeout = 30; _httpServer.ReadBufferSize = 32768; _httpServer.WriteBufferSize = 32768; _httpServer.OnClientConnected = (server, context) => Server_OnConnected(server, context); _httpServer.OnClientDisconnected = (context) => Server_OnDisconnected(context); // Set the header readtimeout. _headerTimeout = _httpServer.HeaderTimeout; // Get the certificate reader. Nequeo.Security.Configuration.Reader certificateReader = new Nequeo.Security.Configuration.Reader(); // Inititalise. _httpServer.Initialisation(); try { // Look for the certificate information in the configuration file. // Get the certificate if any. X509Certificate2 serverCertificate = certificateReader.GetServerCredentials(); // If a certificate exists. if (serverCertificate != null) { // Get the secure servers. _httpServer.Server[2].UseSslConnection = true; _httpServer.Server[2].X509Certificate = serverCertificate; _httpServer.Server[3].UseSslConnection = true; _httpServer.Server[3].X509Certificate = serverCertificate; } } catch { } } catch (Exception) { if (_httpServer != null) { _httpServer.Dispose(); } _httpServer = null; throw; } }