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);
        }
Пример #2
0
        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 WebSocketListener(IPEndPoint endpoint, WebSocketListenerOptions options)
        {
            Guard.ParameterCannotBeNull(endpoint, nameof(endpoint));
            Guard.ParameterCannotBeNull(options, nameof(options));

            _configuration = new WebSocketListenerConfig(options);

            _disposing = new CancellationTokenSource();

            _listener = new TcpListener(endpoint);
            if (_configuration.Options.UseNagleAlgorithm.HasValue)
            {
                _listener.Server.NoDelay = !_configuration.Options.UseNagleAlgorithm.Value;
            }

            _negotiationQueue = new HttpNegotiationQueue(_configuration);
        }
Пример #4
0
        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);
        }
Пример #5
0
        public WebSocketListener(Uri[] listenEndPoints, WebSocketListenerOptions options)
        {
            if (listenEndPoints == null)
            {
                throw new ArgumentNullException(nameof(listenEndPoints));
            }
            if (listenEndPoints.Length == 0)
            {
                throw new ArgumentException("At least one prefix should be specified.", nameof(listenEndPoints));
            }
            if (listenEndPoints.Any(p => p == null))
            {
                throw new ArgumentException("Null objects passed in array.", nameof(listenEndPoints));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            options.CheckCoherence();
            this.options = options.Clone();
            if (this.options.BufferManager == null)
            {
                this.options.BufferManager = BufferManager.CreateBufferManager(100, this.options.SendBufferSize); // create small buffer pool if not configured
            }
            if (this.options.Logger == null)
            {
                this.options.Logger = NullLogger.Instance;
            }
            this.log = this.options.Logger;

            this.listeners       = EmptyListeners;
            this.localEndPoints  = EmptyEndPoints;
            this.listenEndPoints = listenEndPoints;

            this.negotiationQueue = new HttpNegotiationQueue(options.Standards, options.ConnectionExtensions, this.options);
        }