public static IConnectionBuilder UseServer(this IConnectionBuilder builder, IList <IConnectionAdapter> adapters) { return(builder.Use(next => { return context => Task.WhenAll(adapters.Select(a => a.OnConnectionAsync(new ConnectionAdapterContext(context, new RawStream(context.Transport.Input, context.Transport.Output))))); })); }
public static IConnectionBuilder UseHttpServer <TContext>(this IConnectionBuilder builder, IList <IConnectionAdapter> adapters, ServiceContext serviceContext, IHttpApplication <TContext> application, HttpProtocols protocols) { var middleware = new HttpConnectionMiddleware <TContext>(adapters, serviceContext, application, protocols); return(builder.Use(next => { return middleware.OnConnectionAsync; })); }
public static IConnectionBuilder UseHttpServer <TContext>(this IConnectionBuilder builder, ServiceContext serviceContext, IHttpApplication <TContext> application, HttpProtocols protocols) where TContext : notnull { var middleware = new HttpConnectionMiddleware <TContext>(serviceContext, application, protocols); return(builder.Use(next => { return middleware.OnConnectionAsync; })); }
/// <summary> /// Add the given <paramref name="middleware"/> to the connection. /// </summary> /// <param name="connectionBuilder">The <see cref="IConnectionBuilder"/>.</param> /// <param name="middleware">The middleware to add to the <see cref="IConnectionBuilder"/>.</param> /// <returns>The <see cref="IConnectionBuilder"/>.</returns> public static IConnectionBuilder Run(this IConnectionBuilder connectionBuilder, Func <ConnectionContext, Task> middleware) { return(connectionBuilder.Use(next => { return context => { return middleware(context); }; })); }
public static IConnectionBuilder UseTlsFilter( this IConnectionBuilder builder) { return(builder.Use((connection, next) => { /// Write code here to use the connection to filter the connection before the handshake return next(); })); }
public static IConnectionBuilder UseMqttFilter(this IConnectionBuilder builder) { return(builder.Use((connection, next) => { /// Write code here to use the connection to filter the connection before the handshake Console.WriteLine(connection.ConnectionId); return next(); })); }
/// <summary> /// Add the given <paramref name="middleware"/> to the connection. /// </summary> /// <param name="connectionBuilder">The <see cref="IConnectionBuilder"/>.</param> /// <param name="middleware">The middleware to add to the <see cref="IConnectionBuilder"/>.</param> /// <returns>The <see cref="IConnectionBuilder"/>.</returns> public static IConnectionBuilder Use(this IConnectionBuilder connectionBuilder, Func <ConnectionContext, Func <Task>, Task> middleware) { return(connectionBuilder.Use(next => { return context => { Func <Task> simpleNext = () => next(context); return middleware(context, simpleNext); }; })); }
public static IConnectionBuilder UseHttpServer <TContext>(this IConnectionBuilder builder, ServerContext serverContext, IHttpApplication <TContext> application, HttpVersion protocolVersion) { var middleware = new HttpMiddleware <TContext>(serverContext, application, protocolVersion); return(builder.Use(next => { return middleware.OnConnectionAsync; })); }
protected override void ConfigureConnectionBuilder(IConnectionBuilder connectionBuilder) { connectionBuilder.Use(next => { return(async context => { context.Features.Set <IConnectionDirectionFeature>(this); await next(context); }); }); this.clientConnectionOptions.ConfigureConnectionBuilder(connectionBuilder); base.ConfigureConnectionBuilder(connectionBuilder); }
public AspNetCoreRawSocketTransport(IConnectionBuilder app, byte maxSize = 15, TimeSpan?autoPingInterval = null) { if (maxSize >= 16) { throw new ArgumentException("Expected a number between 0 to 15", nameof(maxSize)); } mAutoPingInterval = autoPingInterval; MaxSize = maxSize; mHandler = this.EmptyHandler; app.Use(ConnectionHandler); }
public static void UseClientTls( this IConnectionBuilder builder, TlsOptions options) { if (options is null) { throw new ArgumentNullException(nameof(options)); } var loggerFactory = builder.ApplicationServices.GetService(typeof(ILoggerFactory)) as ILoggerFactory ?? NullLoggerFactory.Instance; builder.Use(next => { var middleware = new TlsClientConnectionMiddleware(next, options, loggerFactory); return(middleware.OnConnectionAsync); }); }
public static IConnectionBuilder UseHttpApplication <TConnection>(this IConnectionBuilder builder) where TConnection : IHttpConnection, new() { return(builder.Use(next => new HttpApplication <TConnection>().ExecuteAsync)); }