Table of Contents

Class NetMiddlewarePipeline

Namespace
Moongate.Network.Pipeline
Assembly
Moongate.Network.dll

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

middlewares IEnumerable<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

middleware INetMiddleware

Middleware 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

true when a matching middleware is registered; otherwise false.

Type Parameters

TMiddleware

Middleware 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

client MoongateTCPClient

Client associated with the payload, if available.

data ReadOnlyMemory<byte>

Incoming payload.

cancellationToken CancellationToken

Cancellation 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

client MoongateTCPClient

Client associated with the payload, if available.

data ReadOnlyMemory<byte>

Outgoing payload.

cancellationToken CancellationToken

Cancellation 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

true when at least one middleware was removed; otherwise false.

Type Parameters

TMiddleware

Middleware type to remove.