Class ClientStore
Local storage of session, sync position, room history, outbox and media metadata; thread-safe as each call uses its own context.
Namespace: Uniform.Matrix.Client.Storage
Assembly: Uniform.Matrix.Client.dll
public sealed class ClientStore
Constructors
|
Edit this page
View Source
ClientStore(IDbContextFactory<ClientDbContext>, TimeProvider)
Create a store over contexts.
Declaration
public ClientStore(IDbContextFactory<ClientDbContext> contexts, TimeProvider time)
Parameters
Fields
|
Edit this page
View Source
How many events of one millisecond get lines of their own; any more share the last.
Declaration
public const long LinesPerMillisecond = 1024
Field Value
Methods
|
Edit this page
View Source
Forget the access token, e.g. after the server rejected it; history is kept.
Declaration
public Task ClearAccessTokenAsync(CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Queue an event for sending with a fixed transaction ID.
Declaration
public Task<OutboxMessage> EnqueueAsync(string roomId, string eventType, object content, CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Return stored media by key, i.e. a content URI optionally with a thumbnail suffix, or null.
Declaration
public Task<StoredMedia?> FindMediaAsync(string key, CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Return stored media of uri, or null when not downloaded.
Declaration
public Task<StoredMedia?> FindMediaAsync(MxcUri uri, CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Return every stored event that is still encrypted and not redacted, with its room.
Declaration
public Task<IReadOnlyList<(string RoomId, ClientEvent Event)>> GetAllEncryptedEventsAsync(CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Return stored events of a room still encrypted with Megolm session sessionId, to retry after its key arrived.
Declaration
public Task<IReadOnlyList<ClientEvent>> GetEncryptedEventsAsync(string roomId, string sessionId, CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Return messages waiting to be sent, oldest first.
Declaration
public Task<IReadOnlyList<OutboxMessage>> GetPendingAsync(CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Return up to limit stored events of a room before beforeTs, oldest first.
Declaration
public Task<IReadOnlyList<ClientEvent>> GetRoomEventsAsync(string roomId, int limit, long? beforeTs = null, CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Return the newest lines stored lines of a room before beforeLine, with every event on them: the event shown and its edits, reactions and redactions.
Declaration
public Task<RoomLines> GetRoomLinesAsync(string roomId, int lines, long? beforeLine = null, CancellationToken cancellationToken = default)
Parameters
| Type |
Name |
Description |
| string |
roomId |
Room ID.
|
| int |
lines |
How many lines at most.
|
| long? |
beforeLine |
Exclusive upper bound of lines, e.g. the OldestLine of the page before; the newest lines when null.
|
| CancellationToken |
cancellationToken |
Cancellation token.
|
Returns
|
Edit this page
View Source
Return the messages (RoomMessage) of a room in the outbox that are not confirmed, for showing them as pending or failed; other events, such as reactions and call signalling, are left out.
Declaration
public Task<IReadOnlyList<OutboxMessage>> GetUnsentAsync(string roomId, CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Return the stored account, or null on first run.
Declaration
public Task<StoredAccount?> LoadAccountAsync(CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Record a failed attempt; permanent failures are not retried.
Declaration
public Task MarkAttemptFailedAsync(long id, string error, bool permanent, CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Mark a message accepted by the server as eventId.
Declaration
public Task MarkSentAsync(long id, string eventId, CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Create or upgrades the database schema.
Declaration
public Task MigrateAsync(CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Replace a stored event, e.g. with its decrypted form.
Declaration
public Task ReplaceEventAsync(ClientEvent clientEvent, CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
SaveHistoryAsync(string, IReadOnlyList<ClientEvent>, CancellationToken)
Store events of roomId loaded from history; already redacted by the server, so no effects are applied.
Declaration
public Task SaveHistoryAsync(string roomId, IReadOnlyList<ClientEvent> events, CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Add or replace media metadata.
Declaration
public Task SaveMediaAsync(StoredMedia media, CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Store session, keeping the sync position when the user is the same.
Declaration
public Task SaveSessionAsync(MatrixSession session, CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Store timeline events of sync, applies redactions, confirms echoed outbox messages and save the sync position, all in one transaction.
Declaration
public Task SaveSyncAsync(SyncResponse sync, string ownUserId, CancellationToken cancellationToken = default)
Parameters
| Type |
Name |
Description |
| SyncResponse |
sync |
Sync response.
|
| string |
ownUserId |
Logged-in user; their echoed events confirm outbox messages.
|
| CancellationToken |
cancellationToken |
Cancellation token.
|
Returns