public WebSocketListener(IPEndPoint endpoint, WebSocketListenerOptions options) { if (options == null) { throw new ArgumentNullException("options"); } if (endpoint == null) { throw new ArgumentNullException("endpoint"); } options.CheckCoherence(); _options = options.Clone(); _cancel = new CancellationTokenSource(); _listener = new TcpListener(endpoint); if (_options.UseNagleAlgorithm.HasValue) { _listener.Server.NoDelay = !_options.UseNagleAlgorithm.Value; } ConnectionExtensions = new WebSocketConnectionExtensionCollection(this); Standards = new WebSocketFactoryCollection(this); _negotiationQueue = new HttpNegotiationQueue(Standards, ConnectionExtensions, options); }
public WebSocketListener(IPEndPoint endpoint, WebSocketListenerOptions options) { if (options == null) { throw new ArgumentNullException("options"); } if (endpoint == null) { throw new ArgumentNullException("endpoint"); } options.CheckCoherence(); _options = options.Clone(); _cancel = new CancellationTokenSource(); _listener = new TcpListener(endpoint); if (_options.UseNagleAlgorithm.HasValue) { _listener.Server.NoDelay = !_options.UseNagleAlgorithm.Value; } ConnectionExtensions = new WebSocketConnectionExtensionCollection(this); Standards = new WebSocketFactoryCollection(this); Func <Socket, Task <WebSocketNegotiationResult> > negotiate = NegotiateWebSocket; _negotiationQueue = new TransformBlock <Socket, WebSocketNegotiationResult>(negotiate, new ExecutionDataflowBlockOptions() { CancellationToken = _cancel.Token, MaxDegreeOfParallelism = options.ParallelNegotiations, BoundedCapacity = options.NegotiationQueueCapacity }); _handShaker = new WebSocketHandshaker(Standards, _options); }
public WebSocketListener(IPEndPoint endpoint, WebSocketListenerOptions options) { Guard.ParameterCannotBeNull(endpoint, "endpoint"); Guard.ParameterCannotBeNull(options, "options"); options.CheckCoherence(); _options = options.Clone(); _cancel = new CancellationTokenSource(); #if NETSTANDARD || UAP _listener = new TcpListener(endpoint); #else if (Type.GetType("Mono.Runtime") == null && _options.UseDualStackSocket) { _listener = TcpListener.Create(endpoint.Port); } else { _listener = new TcpListener(endpoint); } #endif if (_options.UseNagleAlgorithm.HasValue) { _listener.Server.NoDelay = !_options.UseNagleAlgorithm.Value; } ConnectionExtensions = new WebSocketConnectionExtensionCollection(this); Standards = new WebSocketFactoryCollection(this); _negotiationQueue = new HttpNegotiationQueue(Standards, ConnectionExtensions, options); }
public WebSocketHandshaker(WebSocketFactoryCollection factories, WebSocketListenerOptions options) { Guard.ParameterCannotBeNull(factories, "factories"); Guard.ParameterCannotBeNull(options, "options"); _factories = factories; _options = options; }
public WebSocketListenerConfig(WebSocketListenerOptions options) { options.CheckCoherence(); Options = options.Clone(); ConnectionExtensions = new WebSocketConnectionExtensionCollection(); Standards = new WebSocketFactoryCollection(); MessageExtensions = new WebSocketMessageExtensionCollection(); }
internal WebSocketFactoryCollection Clone() { var cloned = new WebSocketFactoryCollection(); foreach (var kv in this.factoryByVersion) { cloned.factoryByVersion[kv.Key] = kv.Value.Clone(); } return(cloned); }
public WebSocketHandshaker(WebSocketFactoryCollection factories, WebSocketListenerOptions options) { if (factories == null) { throw new ArgumentNullException("factories"); } if (options == null) { throw new ArgumentNullException("options"); } _factories = factories; _options = options; }
public WebSocketHandshaker(WebSocketFactoryCollection factories, WebSocketListenerOptions options) { if (factories == null) { throw new ArgumentNullException(nameof(factories)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } this.log = options.Logger; this.factories = factories; this.options = options; }
public WebSocketListener(IPEndPoint endpoint, WebSocketListenerOptions options) { Guard.ParameterCannotBeNull(endpoint, "endpoint"); Guard.ParameterCannotBeNull(options, "options"); options.CheckCoherence(); _options = options.Clone(); _cancel = new CancellationTokenSource(); _listener = new TcpListener(endpoint); if (_options.UseNagleAlgorithm.HasValue) { _listener.Server.NoDelay = !_options.UseNagleAlgorithm.Value; } ConnectionExtensions = new WebSocketConnectionExtensionCollection(this); Standards = new WebSocketFactoryCollection(this); _negotiationQueue = new HttpNegotiationQueue(Standards, ConnectionExtensions, options); }