コード例 #1
0
        /// <summary>
        /// Creates the listener and starts accepting connections over
        /// tcp and tcpv6.
        /// </summary>
        /// <param name="config"></param>
        /// <param name="controller"></param>
        /// <param name="logger"></param>
        public WebSocketChannelListener(IServer controller,
                                        IWebListenerConfig config, ILogger logger)
        {
            _logger = logger ??
                      throw new ArgumentNullException(nameof(logger));
            if (controller?.Callback == null)
            {
                throw new ArgumentNullException(nameof(controller));
            }
            _listenerId = Guid.NewGuid().ToString();
            var configuration = EndpointConfiguration.Create();

            _quotas = new ChannelQuotas {
                MaxBufferSize         = configuration.MaxBufferSize,
                MaxMessageSize        = configuration.MaxMessageSize,
                ChannelLifetime       = configuration.ChannelLifetime,
                SecurityTokenLifetime = configuration.SecurityTokenLifetime,
                MessageContext        = controller.MessageContext,
                CertificateValidator  = controller.CertificateValidator
                                        .GetChannelValidator()
            };
            _bufferManager = new BufferManager("Server", int.MaxValue,
                                               _quotas.MaxBufferSize);
            _urls = (config?.ListenUrls?.Length ?? 0) != 0 ? config.ListenUrls :
                    new string[] { "http://localhost:9040" };
            _controller = controller;
        }
コード例 #2
0
 /// <summary>
 /// Creates middleware to forward requests to controller
 /// </summary>
 /// <param name="controller"></param>
 /// <param name="config"></param>
 /// <param name="logger"></param>
 public HttpChannelListener(IServer controller,
                            IWebListenerConfig config, ILogger logger)
 {
     if (controller?.Callback == null)
     {
         throw new ArgumentNullException(nameof(controller));
     }
     _logger = logger ??
               throw new ArgumentNullException(nameof(logger));
     _listenerId = Guid.NewGuid().ToString();
     _urls       = (config?.ListenUrls?.Length ?? 0) != 0 ? config.ListenUrls :
                   new string[] { "http://localhost:9040" };
     _controller = controller;
 }