/// <summary> /// Initialise. /// </summary> private void Initialise() { // Create the server. _server = new WebServerSingle(_multiEndpointModels, _maxNumClients); // Assign the on connect action handler. _server.Timeout = 60; _server.HeaderTimeout = 30000; _server.RequestTimeout = 30000; _server.ResponseTimeout = 30000; _server.ReadBufferSize = 32768; _server.WriteBufferSize = 32768; _server.ResponseBufferCapacity = 10000000; _server.RequestBufferCapacity = 10000000; _server.MaximumReadLength = 1000000; _server.Name = "Generic Net Server Single"; _server.ServiceName = "GenericNetServerSingle"; _server.OnWebContext += ManagerServer_OnWebContext; // Initialise the server. _server.Initialisation(); }
/// <summary> /// Initialise the server. /// </summary> private void Init() { try { // Create the client list. _clients = new SortedDictionary <string, Nequeo.Net.Data.ConnectionContext>(); _loadServers = Data.Helper.GetLoadBalanceServer(); _contextManager = new Nequeo.Server.SingleContextManager(); string socketProviderHostPrefix = "LoadBalance_"; string hostProviderFullName = socketProviderHostPrefix + "SocketProviderV6"; string hostProviderFullNameSecure = socketProviderHostPrefix + "SocketProviderV6Ssl"; // Get the certificate reader. Nequeo.Security.Configuration.Reader certificateReader = new Nequeo.Security.Configuration.Reader(); Nequeo.Net.Configuration.Reader hostReader = new Nequeo.Net.Configuration.Reader(); // Create the server endpoint. Nequeo.Net.Sockets.MultiEndpointModel[] model = new Nequeo.Net.Sockets.MultiEndpointModel[] { // None secure. new Nequeo.Net.Sockets.MultiEndpointModel() { Port = hostReader.GetServerHost(hostProviderFullName).Port, Addresses = new System.Net.IPAddress[] { System.Net.IPAddress.IPv6Any, System.Net.IPAddress.Any } }, // Secure. new Nequeo.Net.Sockets.MultiEndpointModel() { Port = hostReader.GetServerHost(hostProviderFullNameSecure).Port, Addresses = new System.Net.IPAddress[] { System.Net.IPAddress.IPv6Any, System.Net.IPAddress.Any } } }; // Start the server. _server = new Nequeo.Net.WebServerSingle(model, _maxClient); _server.ServerContextManager = _contextManager; _server.Name = "Load Balance Server"; _server.ServiceName = "LoadBalanceServer"; _server.SocketProviderHostPrefix = socketProviderHostPrefix; _server.OnClientConnected = (context) => ClientConnected(context); _server.OnClientDisconnected = (context) => ClientDisconnected(context); _server.OnWebContext += Server_OnWebContext; _server.Timeout = hostReader.GetServerHost(hostProviderFullName).ClientTimeOut; _server.ReadBufferSize = 32768; _server.WriteBufferSize = 32768; _server.HeaderTimeout = 30000; _server.RequestTimeout = 30000; _server.ResponseTimeout = 30000; _server.ResponseBufferCapacity = 10000000; _server.RequestBufferCapacity = 10000000; _server.MaximumReadLength = 1000000; // Inititalise. _server.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. _server.Server[2].UseSslConnection = true; _server.Server[2].X509Certificate = serverCertificate; _server.Server[3].UseSslConnection = true; _server.Server[3].X509Certificate = serverCertificate; } } catch { } // For each server in the collection. for (int i = 0; i < _server.Server.NumberOfServers; i++) { // Set what needs to be polled. _server.Server[i].PollReader(true); _server.Server[i].PollWriter(false); _server.Server[i].PollError(false); } } catch (Exception) { if (_server != null) { _server.Dispose(); } _server = null; _clients = null; throw; } }