EonaCat.Network/EonaCat.Network/System/Sockets/WebSockets/Client/AsyncWebSocketClientConfigu...

82 lines
3.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Net.Security;
using System.Net.Sockets;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using EonaCat.WebSockets.Buffer;
using EonaCat.WebSockets.Extensions;
using EonaCat.WebSockets.SubProtocols;
namespace EonaCat.WebSockets
{
// This file is part of the EonaCat project(s) which is released under the Apache License.
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
public sealed class AsyncWebSocketClientConfiguration
{
public AsyncWebSocketClientConfiguration()
{
BufferManager = new SegmentBufferManager(100, 8192, 1, true);
ReceiveBufferSize = 8192;
SendBufferSize = 8192;
ReceiveTimeout = TimeSpan.Zero;
SendTimeout = TimeSpan.Zero;
NoDelay = true;
LingerState = new LingerOption(false, 0); // The socket will linger for x seconds after Socket.Close is called.
SslTargetHost = null;
SslClientCertificates = new X509CertificateCollection();
SslEncryptionPolicy = EncryptionPolicy.RequireEncryption;
SslEnabledProtocols = SslProtocols.Ssl3 | SslProtocols.Tls;
SslCheckCertificateRevocation = false;
SslPolicyErrorsBypassed = false;
ConnectTimeout = TimeSpan.FromSeconds(10);
CloseTimeout = TimeSpan.FromSeconds(5);
KeepAliveInterval = TimeSpan.FromSeconds(30);
KeepAliveTimeout = TimeSpan.FromSeconds(5);
ReasonableFragmentSize = 4096;
EnabledExtensions = new Dictionary<string, IWebSocketExtensionNegotiator>()
{
{ PerMessageCompressionExtension.RegisteredToken, new PerMessageCompressionExtensionNegotiator() },
};
EnabledSubProtocols = new Dictionary<string, IWebSocketSubProtocolNegotiator>();
OfferedExtensions = new List<WebSocketExtensionOfferDescription>()
{
new WebSocketExtensionOfferDescription(PerMessageCompressionExtension.RegisteredToken),
};
RequestedSubProtocols = new List<WebSocketSubProtocolRequestDescription>();
}
public ISegmentBufferManager BufferManager { get; set; }
public int ReceiveBufferSize { get; set; }
public int SendBufferSize { get; set; }
public TimeSpan ReceiveTimeout { get; set; }
public TimeSpan SendTimeout { get; set; }
public bool NoDelay { get; set; }
public LingerOption LingerState { get; set; }
public string SslTargetHost { get; set; }
public X509CertificateCollection SslClientCertificates { get; set; }
public EncryptionPolicy SslEncryptionPolicy { get; set; }
public SslProtocols SslEnabledProtocols { get; set; }
public bool SslCheckCertificateRevocation { get; set; }
public bool SslPolicyErrorsBypassed { get; set; }
public TimeSpan ConnectTimeout { get; set; }
public TimeSpan CloseTimeout { get; set; }
public TimeSpan KeepAliveInterval { get; set; }
public TimeSpan KeepAliveTimeout { get; set; }
public int ReasonableFragmentSize { get; set; }
public Dictionary<string, IWebSocketExtensionNegotiator> EnabledExtensions { get; set; }
public Dictionary<string, IWebSocketSubProtocolNegotiator> EnabledSubProtocols { get; set; }
public List<WebSocketExtensionOfferDescription> OfferedExtensions { get; set; }
public List<WebSocketSubProtocolRequestDescription> RequestedSubProtocols { get; set; }
}
}