Class OutboxSender
Sends queued messages in order, keeping them in the database until the server accepts them.
Inherited Members
Namespace: Uniform.Matrix.Client.Services
Assembly: Uniform.Matrix.Client.dll
Syntax
public sealed class OutboxSender
Remarks
Each message keeps its transaction ID across retries and restarts, so the server never stores a resent message twice.
Constructors
| Edit this page View SourceOutboxSender(ClientStore, IOptions<MatrixOptions>, ILogger<OutboxSender>, CryptoService?, SyncProcessor?)
Create a sender over store.
Declaration
public OutboxSender(ClientStore store, IOptions<MatrixOptions> options, ILogger<OutboxSender> logger, CryptoService? crypto = null, SyncProcessor? processor = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ClientStore | store | Queue storage. |
| IOptions<MatrixOptions> | options | Retry settings. |
| ILogger<OutboxSender> | logger | Logger. |
| CryptoService | crypto | Encryption for encrypted rooms; without it, messages to encrypted rooms are refused. |
| SyncProcessor | processor | Room state, to know which rooms are encrypted and who is in them. |
Methods
| Edit this page View SourceEnqueueAsync(string, string, object, CancellationToken)
Queue an event and wakes the sender.
Declaration
public Task<OutboxMessage> EnqueueAsync(string roomId, string eventType, object content, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | roomId | |
| string | eventType | |
| object | content | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<OutboxMessage> |
EnqueueEmoteAsync(string, string, CancellationToken)
Queue an emote, like IRC /me, to roomId and wakes the sender.
Declaration
public Task<OutboxMessage> EnqueueEmoteAsync(string roomId, string text, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | roomId | |
| string | text | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<OutboxMessage> |
EnqueueTextAsync(string, string, CancellationToken)
Queue a text message to roomId and wakes the sender.
Declaration
public Task<OutboxMessage> EnqueueTextAsync(string roomId, string text, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | roomId | |
| string | text | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<OutboxMessage> |
RunAsync(MatrixClient, CancellationToken)
Send pending messages until done or cancellationToken is cancelled, retrying transient failures after OutboxRetryInterval.
Declaration
public Task RunAsync(MatrixClient client, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| MatrixClient | client | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
SendNowAsync(MatrixClient, string, string, object, CancellationToken)
Send an event now, not through the queue, encrypted where the room is, and return its event ID; for events whose ID is needed at once, such as a verification request. Failures are thrown, not retried.
Declaration
public Task<string> SendNowAsync(MatrixClient client, string roomId, string eventType, object content, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| MatrixClient | client | |
| string | roomId | |
| string | eventType | |
| object | content | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<string> |
SendPendingAsync(MatrixClient, CancellationToken)
Send pending messages once; stop at the first transient failure to keep order. Returns the number sent.
Declaration
public Task<int> SendPendingAsync(MatrixClient client, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| MatrixClient | client | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<int> |
Wake()
Try the pending messages again now, e.g. after the network changed, instead of after the retry interval.
Declaration
public void Wake()
Events
| Edit this page View SourceRoomChanged
Raised with the room ID when a message of that room is queued, sent or failed; fires on the sending thread.
Declaration
public event Action<string>? RoomChanged
Event Type
| Type | Description |
|---|---|
| Action<string> |