Class NetMiddlewarePipeline
Executes network middleware components in registration order.
public sealed class NetMiddlewarePipeline
- Inheritance
-
NetMiddlewarePipeline
- Inherited Members
Constructors
NetMiddlewarePipeline(IEnumerable<INetMiddleware>?)
Initializes the middleware pipeline.
public NetMiddlewarePipeline(IEnumerable<INetMiddleware>? middlewares = null)
Parameters
middlewaresIEnumerable<INetMiddleware>Optional initial middleware sequence.
Methods
AddMiddleware(INetMiddleware)
Adds a middleware component at the end of the execution chain.
public void AddMiddleware(INetMiddleware middleware)
Parameters
middlewareINetMiddlewareMiddleware to register.
ContainsMiddleware<TMiddleware>()
Checks whether at least one middleware component of the specified type is registered.
public bool ContainsMiddleware<TMiddleware>() where TMiddleware : INetMiddleware
Returns
- bool
truewhen a matching middleware is registered; otherwisefalse.
Type Parameters
TMiddlewareMiddleware type to check.
ExecuteAsync(MoongateTCPClient?, ReadOnlyMemory<byte>, CancellationToken)
Processes the payload through all registered middleware components.
public ValueTask<ReadOnlyMemory<byte>> ExecuteAsync(MoongateTCPClient? client, ReadOnlyMemory<byte> data, CancellationToken cancellationToken)
Parameters
clientMoongateTCPClientClient associated with the payload, if available.
dataReadOnlyMemory<byte>Incoming payload.
cancellationTokenCancellationTokenCancellation token.
Returns
- ValueTask<ReadOnlyMemory<byte>>
The processed payload, or empty when dropped by middleware.
ExecuteSendAsync(MoongateTCPClient?, ReadOnlyMemory<byte>, CancellationToken)
Processes the outgoing payload through all registered middleware components.
public ValueTask<ReadOnlyMemory<byte>> ExecuteSendAsync(MoongateTCPClient? client, ReadOnlyMemory<byte> data, CancellationToken cancellationToken)
Parameters
clientMoongateTCPClientClient associated with the payload, if available.
dataReadOnlyMemory<byte>Outgoing payload.
cancellationTokenCancellationTokenCancellation token.
Returns
- ValueTask<ReadOnlyMemory<byte>>
The processed payload, or empty when dropped by middleware.
RemoveMiddleware<TMiddleware>()
Removes all middleware components of the specified type.
public bool RemoveMiddleware<TMiddleware>() where TMiddleware : INetMiddleware
Returns
- bool
truewhen at least one middleware was removed; otherwisefalse.
Type Parameters
TMiddlewareMiddleware type to remove.