Class MessageContext
- Namespace
- Signal.Application.Pipeline
- Assembly
- Signal.Application.dll
Per-envelope state flowing through the middleware pipeline. Each envelope gets its own DI scope,
so scoped services (middleware, handlers, commands, DbContexts, …) live exactly as long as the message.
public sealed class MessageContext
- Inheritance
-
MessageContext
- Inherited Members
- Extension Methods
Constructors
MessageContext(IncomingEnvelope, IServiceProvider, CancellationToken)
Per-envelope state flowing through the middleware pipeline. Each envelope gets its own DI scope,
so scoped services (middleware, handlers, commands, DbContexts, …) live exactly as long as the message.
public MessageContext(IncomingEnvelope envelope, IServiceProvider services, CancellationToken cancellationToken)
Parameters
envelopeIncomingEnvelopeThe received envelope.
servicesIServiceProviderThe scoped service provider of this message.
cancellationTokenCancellationTokenCancelled when the host shuts down.
Properties
Account
The receiving account.
public PhoneNumber Account { get; }
Property Value
CancellationToken
Cancelled when the host shuts down.
public CancellationToken CancellationToken { get; }
Property Value
Conversation
Where replies go: the group, or the sender for direct messages.
public Recipient Conversation { get; }
Property Value
Envelope
The received envelope.
public IncomingEnvelope Envelope { get; }
Property Value
IsHandled
Set when a component fully handled the message (e.g. a command was executed).
public bool IsHandled { get; set; }
Property Value
Items
Arbitrary data shared between middlewares (e.g. the CommandResult is stored under its type).
public IDictionary<object, object?> Items { get; }
Property Value
Sender
The sender of the envelope.
public Sender Sender { get; }
Property Value
Services
The scoped service provider of this message.
public IServiceProvider Services { get; }
Property Value
Methods
ReplyAsync(OutgoingMessage, CancellationToken)
Sends a prepared message using the account that received this envelope.
public Task<SendResult> ReplyAsync(OutgoingMessage message, CancellationToken cancellationToken = default)
Parameters
messageOutgoingMessageThe message; its recipients are used as-is.
cancellationTokenCancellationTokenCancels the send; defaults to CancellationToken.
Returns
- Task<SendResult>
The send result.
ReplyAsync(string, bool, CancellationToken)
Sends a text into the conversation this envelope belongs to.
public Task<SendResult> ReplyAsync(string text, bool quote = false, CancellationToken cancellationToken = default)
Parameters
textstringThe reply text.
quoteboolQuote the received data message in the reply.
cancellationTokenCancellationTokenCancels the send; defaults to CancellationToken.
Returns
- Task<SendResult>
The send result.