Exemplo n.º 1
0
        public WebSocketPackageHandler(IServiceProvider serviceProvider, IOptions <HandshakeOptions> handshakeOptions)
        {
            _serviceProvider = serviceProvider;

            _websocketCommandMiddleware = serviceProvider
                                          .GetService <IWebSocketCommandMiddleware>() as IPackageHandler <WebSocketPackage>;

            _packageHandlerDelegate = serviceProvider.GetService <Func <WebSocketSession, WebSocketPackage, Task> >();
            _subProtocolSelector    = serviceProvider.GetService <ISubProtocolSelector>();
            _handshakeOptions       = handshakeOptions.Value;
        }
        public WebSocketServerMiddleware(IOptions <HandshakeOptions> handshakeOptions)
        {
            var options = handshakeOptions.Value;

            if (options == null)
            {
                options = new HandshakeOptions();
            }

            _options = options;
        }
        public HandshakeCheckMiddleware(IOptions <HandshakeOptions> handshakeOptions)
        {
            var options = handshakeOptions.Value;

            if (options == null)
            {
                options = new HandshakeOptions();
            }

            _options = options;
        }
        public WebSocketPackageHandler(IServiceProvider serviceProvider, ILoggerFactory loggerFactory, IOptions <HandshakeOptions> handshakeOptions)
        {
            _serviceProvider = serviceProvider;

            _websocketCommandMiddleware = serviceProvider
                                          .GetService <IWebSocketCommandMiddleware>() as IPackageHandler <WebSocketPackage>;

            _subProtocolHandlers    = serviceProvider.GetServices <ISubProtocolHandler>().ToDictionary(h => h.Name, StringComparer.OrdinalIgnoreCase);
            _packageHandlerDelegate = serviceProvider.GetService <Func <WebSocketSession, WebSocketPackage, ValueTask> >();
            _logger           = loggerFactory.CreateLogger <WebSocketPackageHandler>();
            _handshakeOptions = handshakeOptions.Value;
        }