Interface IMessageMiddleware
- Namespace
- Signal.Application.Pipeline
- Assembly
- Signal.Application.dll
A step of the incoming message pipeline (ASP.NET Core style). Instances are resolved from the message's DI scope, so constructor injection of scoped services is supported.
public interface IMessageMiddleware
Examples
public sealed class TypingMiddleware(ITypingIndicatorService typing) : IMessageMiddleware
{
public async Task InvokeAsync(MessageContext context, MessageDelegate next)
{
await typing.StartTypingAsync(context.Account, context.Conversation);
try { await next(context); }
finally { await typing.StopTypingAsync(context.Account, context.Conversation); }
}
}
Methods
InvokeAsync(MessageContext, MessageDelegate)
Processes the message. Call next to continue; skip it to stop processing.
Task InvokeAsync(MessageContext context, MessageDelegate next)
Parameters
contextMessageContextThe message being processed.
nextMessageDelegateThe rest of the pipeline.
Returns
- Task
A task that completes when this step (and everything it invoked) has finished.