namespace WatsonTcp { using System; using System.Collections.Generic; /// /// Settings for Watson TCP server. /// public class WatsonTcpServerSettings { #region Public-Members /// /// Buffer size to use when reading input and output streams. Default is 65536. Value must be greater than zero. /// public int StreamBufferSize { get { return _StreamBufferSize; } set { if (value < 1) throw new ArgumentException("Stream buffer size must be greater than zero."); _StreamBufferSize = value; } } /// /// Maximum content length for streams that are proxied through a MemoryStream. /// If the content length exceeds this value, the underlying DataStream will be passed in the StreamReceived event. /// Value must be greater than zero. /// public int MaxProxiedStreamSize { get { return _MaxProxiedStreamSize; } set { if (value < 1) throw new ArgumentException("MaxProxiedStreamSize must be greater than zero."); _MaxProxiedStreamSize = value; } } /// /// Server GUID. /// public Guid Guid { get; set; } = Guid.NewGuid(); /// /// Enable or disable message debugging. Requires `Logger` to be set. /// WARNING: Setting this value to true will emit a large number of log messages with a large amount of data. /// public bool DebugMessages { get; set; } = false; /// /// Method to invoke when sending a log message. /// public Action Logger { get; set; } = null; /// /// Enable acceptance of SSL certificates from clients that cannot be validated. /// public bool AcceptInvalidCertificates { get; set; } = true; /// /// Require mutual authentication between SSL clients and this server. /// public bool MutuallyAuthenticate { get; set; } = false; /// /// Preshared key that must be consistent between clients and this server. /// public string PresharedKey { get; set; } = null; /// /// For Watson TCP server, the maximum amount of time to wait before considering a client idle and disconnecting them. /// By default, this value is set to 0, which will never disconnect a client due to inactivity. /// The timeout is reset any time a message is received from a client or a message is sent to a client. /// For instance, if you set this value to 30, the client will be disconnected if the server has not received a message from the client within 30 seconds or if a message has not been sent to the client in 30 seconds. /// Value must be zero or greater. /// public int IdleClientTimeoutSeconds { get { return _IdleClientTimeoutSeconds; } set { if (value < 0) throw new ArgumentException("IdleClientTimeoutSeconds must be zero or greater."); _IdleClientTimeoutSeconds = value; } } /// /// For Watson TCP server, specify the maximum number of connections the server will accept. /// Default is 4096. Value must be greater than zero. /// public int MaxConnections { get { return _MaxConnections; } set { if (value < 1) throw new ArgumentException("Max connections must be greater than zero."); _MaxConnections = value; } } /// /// For Watson TCP server, the list of permitted IP addresses from which connections can be received. /// public List PermittedIPs { get { return _PermittedIPs; } set { if (value == null) _PermittedIPs = new List(); else _PermittedIPs = value; } } /// /// For Watson TCP server, the list of blocked IP addresses from which connections will be declined. /// public List BlockedIPs { get { return _BlockedIPs; } set { if (value == null) _BlockedIPs = new List(); else _BlockedIPs = value; } } /// /// Nagle's algorithm. Disable the delay when send or receive buffers are not full. If true, disable the delay. Default is true. /// public bool NoDelay { get; set; } = true; #endregion #region Private-Members private int _StreamBufferSize = 65536; private int _MaxProxiedStreamSize = 67108864; private int _MaxConnections = 4096; private int _IdleClientTimeoutSeconds = 0; private List _PermittedIPs = new List(); private List _BlockedIPs = new List(); #endregion #region Constructors-and-Factories /// /// Instantiate. /// public WatsonTcpServerSettings() { } #endregion #region Public-Methods #endregion #region Private-Methods #endregion } }