Table of Contents

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

envelope IncomingEnvelope

The received envelope.

services IServiceProvider

The scoped service provider of this message.

cancellationToken CancellationToken

Cancelled when the host shuts down.

Properties

Account

The receiving account.

public PhoneNumber Account { get; }

Property Value

PhoneNumber

CancellationToken

Cancelled when the host shuts down.

public CancellationToken CancellationToken { get; }

Property Value

CancellationToken

Conversation

Where replies go: the group, or the sender for direct messages.

public Recipient Conversation { get; }

Property Value

Recipient

Envelope

The received envelope.

public IncomingEnvelope Envelope { get; }

Property Value

IncomingEnvelope

IsHandled

Set when a component fully handled the message (e.g. a command was executed).

public bool IsHandled { get; set; }

Property Value

bool

Items

Arbitrary data shared between middlewares (e.g. the CommandResult is stored under its type).

public IDictionary<object, object?> Items { get; }

Property Value

IDictionary<object, object>

Sender

The sender of the envelope.

public Sender Sender { get; }

Property Value

Sender

Services

The scoped service provider of this message.

public IServiceProvider Services { get; }

Property Value

IServiceProvider

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

message OutgoingMessage

The message; its recipients are used as-is.

cancellationToken CancellationToken

Cancels 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

text string

The reply text.

quote bool

Quote the received data message in the reply.

cancellationToken CancellationToken

Cancels the send; defaults to CancellationToken.

Returns

Task<SendResult>

The send result.