Class RoomStore
Client-side state of all rooms, built by applying sync responses; not thread-safe.
Namespace: Uniform.Matrix.Client.State
Assembly: Uniform.Matrix.Client.dll
public sealed class RoomStore
RoomStore store = new(client.UserId!);
await foreach (SyncResponse sync in client.SyncLoopAsync(ct: ct))
{
SyncChanges changes = store.Apply(sync);
foreach (TimelineBatch batch in changes.Timeline)
foreach (ClientEvent ev in batch.Events)
if (ev.TryGetContent(out MessageContent? message)) Console.WriteLine($"[{batch.Room.DisplayName}] {batch.Room.GetMemberDisplayName(ev.Sender)}: {message.Body}");
}
Constructors
|
Edit this page
View Source
Create an empty store for the logged-in ownUserId.
Declaration
public RoomStore(string ownUserId)
Parameters
| Type |
Name |
Description |
| string |
ownUserId |
|
Properties
|
Edit this page
View Source
Global account data keyed by type.
Declaration
public IReadOnlyDictionary<string, MatrixEvent> AccountData { get; }
Property Value
|
Edit this page
View Source
Declaration
public IReadOnlySet<string> IgnoredUsers { get; }
Property Value
|
Edit this page
View Source
Most events kept per room by sync; backfilled events come on top.
Declaration
public int MaxTimelineLength { get; init; }
Property Value
|
Edit this page
View Source
NextBatch of the last applied sync; stores it to resume syncing.
Declaration
public string? NextBatch { get; }
Property Value
|
Edit this page
View Source
Logged-in user, excluded from computed room names.
Declaration
public string OwnUserId { get; }
Property Value
|
Edit this page
View Source
Latest presence keyed by user ID.
Declaration
public IReadOnlyDictionary<string, PresenceContent> Presence { get; }
Property Value
|
Edit this page
View Source
Known rooms of every membership keyed by room ID.
Declaration
public IReadOnlyDictionary<string, Room> Rooms { get; }
Property Value
Methods
|
Edit this page
View Source
Apply sync and return what changed.
Declaration
public SyncChanges Apply(SyncResponse sync)
Parameters
Returns
|
Edit this page
View Source
ApplyHistory(Room, MessagesResponse)
Prepend a backward page fetched from HistoryToken; return its events oldest first.
Declaration
public IReadOnlyList<ClientEvent> ApplyHistory(Room room, MessagesResponse page)
Parameters
Returns
|
Edit this page
View Source
Declaration
public void ApplyMembers(Room room, IReadOnlyList<ClientEvent> memberEvents)
Parameters
|
Edit this page
View Source
Load up to limit events older than Timeline and prepend them; return them oldest first.
Declaration
public Task<IReadOnlyList<ClientEvent>> BackfillAsync(MatrixClient client, Room room, int limit = 50, CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Whether room has a token for older history; clears HasMoreHistory when it never will.
Declaration
public static bool CanBackfill(Room room)
Parameters
| Type |
Name |
Description |
| Room |
room |
|
Returns
|
Edit this page
View Source
Load the full member list, which sync omits when lazy-loading members.
Declaration
public Task LoadMembersAsync(MatrixClient client, Room room, CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Replace IgnoredUsers at once, e.g. right after changing the list on the server, before the sync brings it.
Declaration
public void SetIgnoredUsers(IEnumerable<string> userIds)
Parameters
|
Edit this page
View Source
Return a known room by ID.
Declaration
public bool TryGetRoom(string roomId, out Room? room)
Parameters
Returns