public WebSocketConnectionListener(KestrelServer server, IServiceProvider serviceProvider, string path)
        {
            _server = server;
            var builder = new ApplicationBuilder(serviceProvider);

            builder.UseRouting();
            builder.UseEndpoints(routes =>
            {
                routes.MapConnections(path, cb => cb.Run(inner =>
                {
                    var connection = new WebSocketConnectionContext(inner);

                    _acceptQueue.Writer.TryWrite(connection);

                    return(connection.ExecutionTask);
                }));
            });

            _application = builder.Build();
        }
Beispiel #2
0
        public WebSocketConnectionListener(KestrelServer server, Action <Microsoft.AspNetCore.Http.Connections.WebSocketOptions> configure, IServiceProvider serviceProvider, string path)
        {
            _server = server;
            var builder = new ApplicationBuilder(serviceProvider);

            builder.UseRouting();
            builder.UseEndpoints(routes =>
            {
                var options = new HttpConnectionDispatcherOptions();
                configure(options.WebSockets);
                routes.MapConnections(path, options, cb => cb.Run(inner =>
                {
                    var connection = new WebSocketConnectionContext(inner);

                    _acceptQueue.Writer.TryWrite(connection);

                    return(connection.ExecutionTask);
                }));
            });

            _application = builder.Build();
        }