BVB Source Codes

SuperSocket v1.6.6 Show ServerConfig.cs Source code

Return Download SuperSocket v1.6.6: download ServerConfig.cs Source code - Download SuperSocket v1.6.6 Source code - Type:.cs
  1. 锘縰sing System;
  2. using System.Collections.Generic;
  3. using System.Collections.Specialized;
  4. using System.Configuration;
  5. using System.Linq;
  6. using System.Security.Authentication;
  7. using System.Text;
  8. using SuperSocket.Common;
  9.  
  10. namespace SuperSocket.SocketBase.Config
  11. {
  12.     /// <summary>
  13.     /// Server configruation model
  14.     /// </summary>
  15.     [Serializable]
  16.     public partial class ServerConfig : IServerConfig
  17.     {
  18.         /// <summary>
  19.         /// Default ReceiveBufferSize
  20.         /// </summary>
  21.         public const int DefaultReceiveBufferSize = 4096;
  22.  
  23.         /// <summary>
  24.         /// Default MaxConnectionNumber
  25.         /// </summary>
  26.         public const int DefaultMaxConnectionNumber = 100;
  27.  
  28.  
  29.         /// <summary>
  30.         /// Default sending queue size
  31.         /// </summary>
  32.         public const int DefaultSendingQueueSize = 5;
  33.  
  34.         /// <summary>
  35.         /// Default MaxRequestLength
  36.         /// </summary>
  37.         public const int DefaultMaxRequestLength = 1024;
  38.  
  39.  
  40.         /// <summary>
  41.         /// Default send timeout value, in milliseconds
  42.         /// </summary>
  43.         public const int DefaultSendTimeout = 5000;
  44.  
  45.  
  46.         /// <summary>
  47.         /// Default clear idle session interval
  48.         /// </summary>
  49.         public const int DefaultClearIdleSessionInterval = 120;
  50.  
  51.  
  52.         /// <summary>
  53.         /// Default idle session timeout
  54.         /// </summary>
  55.         public const int DefaultIdleSessionTimeOut = 300;
  56.  
  57.  
  58.         /// <summary>
  59.         /// The default send buffer size
  60.         /// </summary>
  61.         public const int DefaultSendBufferSize = 2048;
  62.  
  63.  
  64.         /// <summary>
  65.         /// The default session snapshot interval
  66.         /// </summary>
  67.         public const int DefaultSessionSnapshotInterval = 5;
  68.  
  69.         /// <summary>
  70.         /// The default keep alive time
  71.         /// </summary>
  72.         public const int DefaultKeepAliveTime = 600; // 60 * 10 = 10 minutes
  73.  
  74.  
  75.         /// <summary>
  76.         /// The default keep alive interval
  77.         /// </summary>
  78.         public const int DefaultKeepAliveInterval = 60; // 60 seconds
  79.  
  80.  
  81.         /// <summary>
  82.         /// The default listen backlog
  83.         /// </summary>
  84.         public const int DefaultListenBacklog = 100;
  85.  
  86.  
  87.         /// <summary>
  88.         /// Initializes a new instance of the <see cref="ServerConfig"/> class.
  89.         /// </summary>
  90.         /// <param name="serverConfig">The server config.</param>
  91.         public ServerConfig(IServerConfig serverConfig)
  92.         {
  93.             serverConfig.CopyPropertiesTo(this);
  94.            
  95.             this.Options = serverConfig.Options;
  96.             this.OptionElements = serverConfig.OptionElements;
  97.  
  98.             if (serverConfig.Certificate != null)
  99.                 this.Certificate = serverConfig.Certificate.CopyPropertiesTo(new CertificateConfig());
  100.  
  101.             if (serverConfig.Listeners != null && serverConfig.Listeners.Any())
  102.             {
  103.                 this.Listeners = serverConfig.Listeners.Select(l => l.CopyPropertiesTo(new ListenerConfig())).OfType<ListenerConfig>().ToArray();
  104.             }
  105.  
  106.             if (serverConfig.CommandAssemblies != null && serverConfig.CommandAssemblies.Any())
  107.             {
  108.                 this.CommandAssemblies = serverConfig.CommandAssemblies.Select(c => c.CopyPropertiesTo(new CommandAssemblyConfig())).OfType<CommandAssemblyConfig>().ToArray();
  109.             }
  110.         }
  111.  
  112.         /// <summary>
  113.         /// Initializes a new instance of the <see cref="ServerConfig"/> class.
  114.         /// </summary>
  115.         public ServerConfig()
  116.         {
  117.             Security = "None";
  118.             MaxConnectionNumber = DefaultMaxConnectionNumber;
  119.             Mode = SocketMode.Tcp;
  120.             MaxRequestLength = DefaultMaxRequestLength;
  121.             KeepAliveTime = DefaultKeepAliveTime;
  122.             KeepAliveInterval = DefaultKeepAliveInterval;
  123.             ListenBacklog = DefaultListenBacklog;
  124.             ReceiveBufferSize = DefaultReceiveBufferSize;
  125.             SendingQueueSize = DefaultSendingQueueSize;
  126.             SendTimeOut = DefaultSendTimeout;
  127.             ClearIdleSessionInterval = DefaultClearIdleSessionInterval;
  128.             IdleSessionTimeOut = DefaultIdleSessionTimeOut;
  129.             SendBufferSize = DefaultSendBufferSize;
  130.             LogBasicSessionActivity = true;
  131.             SessionSnapshotInterval = DefaultSessionSnapshotInterval;
  132.         }
  133.  
  134.         #region IServerConfig Members
  135.  
  136.         /// <summary>
  137.         /// Gets/sets the name of the server type of this appServer want to use.
  138.         /// </summary>
  139.         /// <value>
  140.         /// The name of the server type.
  141.         /// </value>
  142.         public string ServerTypeName { get; set; }
  143.  
  144.  
  145.         /// <summary>
  146.         /// Gets/sets the type definition of the appserver.
  147.         /// </summary>
  148.         /// <value>
  149.         /// The type of the server.
  150.         /// </value>
  151.         public string ServerType { get; set; }
  152.  
  153.         /// <summary>
  154.         /// Gets/sets the Receive filter factory.
  155.         /// </summary>
  156.         public string ReceiveFilterFactory { get; set; }
  157.  
  158.         /// <summary>
  159.         /// Gets/sets the ip.
  160.         /// </summary>
  161.         public string Ip { get; set; }
  162.  
  163.         /// <summary>
  164.         /// Gets/sets the port.
  165.         /// </summary>
  166.         public int Port { get; set; }
  167.  
  168.         /// <summary>
  169.         /// Gets/sets the options.
  170.         /// </summary>
  171.         [HotUpdate]
  172.         public NameValueCollection Options { get; set; }
  173.  
  174.         /// <summary>
  175.         /// Gets the option elements.
  176.         /// </summary>
  177.         [HotUpdate]
  178.         public NameValueCollection OptionElements { get; set; }
  179.  
  180.         /// <summary>
  181.         /// Gets/sets a value indicating whether this <see cref="IServerConfig"/> is disabled.
  182.         /// </summary>
  183.         /// <value>
  184.         ///   <c>true</c> if disabled; otherwise, <c>false</c>.
  185.         /// </value>
  186.         public bool Disabled { get; set; }
  187.  
  188.         /// <summary>
  189.         /// Gets the name.
  190.         /// </summary>
  191.         public string Name { get; set; }
  192.  
  193.         /// <summary>
  194.         /// Gets/sets the mode.
  195.         /// </summary>
  196.         public SocketMode Mode { get; set; }
  197.  
  198.         /// <summary>
  199.         /// Gets/sets the send time out.
  200.         /// </summary>
  201.         public int SendTimeOut { get; set; }
  202.  
  203.         /// <summary>
  204.         /// Gets the max connection number.
  205.         /// </summary>
  206.         public int MaxConnectionNumber { get; set; }
  207.  
  208.         /// <summary>
  209.         /// Gets the size of the receive buffer.
  210.         /// </summary>
  211.         /// <value>
  212.         /// The size of the receive buffer.
  213.         /// </value>
  214.         public int ReceiveBufferSize { get; set; }
  215.  
  216.         /// <summary>
  217.         /// Gets the size of the send buffer.
  218.         /// </summary>
  219.         /// <value>
  220.         /// The size of the send buffer.
  221.         /// </value>
  222.         public int SendBufferSize { get; set; }
  223.  
  224.  
  225.         /// <summary>
  226.         /// Gets a value indicating whether sending is in synchronous mode.
  227.         /// </summary>
  228.         /// <value>
  229.         ///   <c>true</c> if [sync send]; otherwise, <c>false</c>.
  230.         /// </value>
  231.         public bool SyncSend { get; set; }
  232.  
  233.         /// <summary>
  234.         /// Gets/sets a value indicating whether log command in log file.
  235.         /// </summary>
  236.         /// <value>
  237.         ///   <c>true</c> if log command; otherwise, <c>false</c>.
  238.         /// </value>
  239.         [HotUpdate]
  240.         public bool LogCommand { get; set; }
  241.  
  242.         /// <summary>
  243.         /// Gets/sets a value indicating whether clear idle session.
  244.         /// </summary>
  245.         /// <value>
  246.         ///   <c>true</c> if clear idle session; otherwise, <c>false</c>.
  247.         /// </value>
  248.         public bool ClearIdleSession { get; set; }
  249.  
  250.         /// <summary>
  251.         /// Gets/sets the clear idle session interval, in seconds.
  252.         /// </summary>
  253.         /// <value>
  254.         /// The clear idle session interval.
  255.         /// </value>
  256.         public int ClearIdleSessionInterval { get; set; }
  257.  
  258.         /// <summary>
  259.         /// Gets/sets the idle session timeout time length, in seconds.
  260.         /// </summary>
  261.         /// <value>
  262.         /// The idle session time out.
  263.         /// </value>
  264.         [HotUpdate]
  265.         public int IdleSessionTimeOut { get; set; }
  266.  
  267.         /// <summary>
  268.         /// Gets/sets X509Certificate configuration.
  269.         /// </summary>
  270.         /// <value>
  271.         /// X509Certificate configuration.
  272.         /// </value>
  273.         public ICertificateConfig Certificate { get; set; }
  274.  
  275.         /// <summary>
  276.         /// Gets/sets the security protocol, X509 certificate.
  277.         /// </summary>
  278.         public string Security { get; set; }
  279.  
  280.         /// <summary>
  281.         /// Gets/sets the length of the max request.
  282.         /// </summary>
  283.         /// <value>
  284.         /// The length of the max request.
  285.         /// </value>
  286.         [HotUpdate]
  287.         public int MaxRequestLength { get; set; }
  288.  
  289.         /// <summary>
  290.         /// Gets/sets a value indicating whether [disable session snapshot].
  291.         /// </summary>
  292.         /// <value>
  293.         ///     <c>true</c> if [disable session snapshot]; otherwise, <c>false</c>.
  294.         /// </value>
  295.         public bool DisableSessionSnapshot { get; set; }
  296.  
  297.         /// <summary>
  298.         /// Gets/sets the interval to taking snapshot for all live sessions.
  299.         /// </summary>
  300.         public int SessionSnapshotInterval { get; set; }
  301.  
  302.         /// <summary>
  303.         /// Gets/sets the connection filters used by this server instance.
  304.         /// </summary>
  305.         /// <value>
  306.         /// The connection filter's name list, seperated by comma
  307.         /// </value>
  308.         public string ConnectionFilter { get; set; }
  309.  
  310.         /// <summary>
  311.         /// Gets the command loader, multiple values should be separated by comma.
  312.         /// </summary>
  313.         public string CommandLoader { get; set; }
  314.  
  315.         /// <summary>
  316.         /// Gets/sets the start keep alive time, in seconds
  317.         /// </summary>
  318.         public int KeepAliveTime { get; set; }
  319.  
  320.         /// <summary>
  321.         /// Gets/sets the keep alive interval, in seconds.
  322.         /// </summary>
  323.         public int KeepAliveInterval { get; set; }
  324.  
  325.         /// <summary>
  326.         /// Gets the backlog size of socket listening.
  327.         /// </summary>
  328.         public int ListenBacklog { get; set; }
  329.  
  330.         /// <summary>
  331.         /// Gets/sets the startup order of the server instance.
  332.         /// </summary>
  333.         public int StartupOrder { get; set; }
  334.  
  335.         /// <summary>
  336.         /// Gets the child config.
  337.         /// </summary>
  338.         /// <typeparam name="TConfig">The type of the config.</typeparam>
  339.         /// <param name="childConfigName">Name of the child config.</param>
  340.         /// <returns></returns>
  341.         public virtual TConfig GetChildConfig<TConfig>(string childConfigName)
  342.             where TConfig : ConfigurationElement, new()
  343.         {
  344.             return this.OptionElements.GetChildConfig<TConfig>(childConfigName);
  345.         }
  346.  
  347.         /// <summary>
  348.         /// Gets and sets the listeners' configuration.
  349.         /// </summary>
  350.         public IEnumerable<IListenerConfig> Listeners { get; set; }
  351.  
  352.         /// <summary>
  353.         /// Gets/sets the log factory name.
  354.         /// </summary>
  355.         public string LogFactory { get; set; }
  356.  
  357.         /// <summary>
  358.         /// Gets/sets the size of the sending queue.
  359.         /// </summary>
  360.         /// <value>
  361.         /// The size of the sending queue.
  362.         /// </value>
  363.         public int SendingQueueSize { get; set; }
  364.  
  365.         /// <summary>
  366.         /// Gets a value indicating whether [log basic session activity like connected and disconnected].
  367.         /// </summary>
  368.         /// <value>
  369.         ///     <c>true</c> if [log basic session activity]; otherwise, <c>false</c>.
  370.         /// </value>
  371.         [HotUpdate]
  372.         public bool LogBasicSessionActivity { get; set; }
  373.  
  374.         /// <summary>
  375.         /// Gets/sets a value indicating whether [log all socket exception].
  376.         /// </summary>
  377.         /// <value>
  378.         /// <c>true</c> if [log all socket exception]; otherwise, <c>false</c>.
  379.         /// </value>
  380.         [HotUpdate]
  381.         public bool LogAllSocketException { get; set; }
  382.  
  383.         /// <summary>
  384.         /// Gets/sets the default text encoding.
  385.         /// </summary>
  386.         /// <value>
  387.         /// The text encoding.
  388.         /// </value>
  389.         public string TextEncoding { get; set; }
  390.  
  391.         /// <summary>
  392.         /// Gets the command assemblies configuration.
  393.         /// </summary>
  394.         /// <value>
  395.         /// The command assemblies.
  396.         /// </value>
  397.         public IEnumerable<ICommandAssemblyConfig> CommandAssemblies { get; set; }
  398.  
  399.         #endregion
  400.     }
  401. }
  402.  
downloadServerConfig.cs Source code - Download SuperSocket v1.6.6 Source code
Related Source Codes/Software:
Students' basic information input program v2.0 - 1, the program is based on. net4.0 framework and d... 2016-08-19
Student information input system v2.0 - 1, the program is based on. net4.0 framework and d... 2016-08-19
Baidu handwriting input source v1.0 - Baidu handwriting input method source code, no nee... 2016-08-19
Rui bao tong v1.0 JAVA version of B2B e-commerce system - Rainbow B2B system developed using the popular JAV... 2016-08-19
HTML + javascript lottery system v2.1.1 HTA - Technology QQ:838341952 HTML+JS lottery system sta... 2016-08-19
Cloud on the CMS (SyCms) v1.95 - Add menus and blocks the system style functionalit... 2016-08-19
1.0 housing, rental housing sale platform - Rent housing rent out platform is a very typical r... 2016-08-19
Deng Xi v2.4 website help system - Deng Xi website help system is a very useful help ... 2016-08-19
Address book v1.0 FaLiang three layer - This Demo is a three layer address book source cod... 2016-08-19
Ray speed v7.0 wage query system - To modify the software to conduct a comprehensive ... 2016-08-19
MTStatusBarOverlay - A custom iOS status bar overlay seen in Apps like ... 2017-05-12
blueprint - Reverse engineer server configuration ... 2017-05-12
PullToRefresh - A simple iPhone TableViewController for adding the... 2017-05-12
mrjob - Run MapReduce jobs on Hadoop or Amazon Web Service... 2017-05-11
wax - Wax is now being maintained by alibaba ... 2017-05-11
ledisdb - a high performance NoSQL powered by Go ... 2017-05-11
d3-cloud - Create word clouds in JavaScript. ... 2017-05-11
react-makes-you-sad - Here's a flowchart to make you happy again! 2017-05-11
flat-surface-shader - Flat Surface Shader for rendering lit triangles to... 2017-05-11
flat-surface-shader - Flat Surface Shader for rendering lit triangles to... 2017-05-11

 Back to top