Class SyncService
Sync, room history and event context for local users.
Inherited Members
Namespace: Uniform.Matrix.Server.Sync
Assembly: Uniform.Matrix.Server.dll
Syntax
public sealed class SyncService
Remarks
Tokens are s and a ServerStream position. prev_batch and pagination tokens use the same form: /messages backwards from sN returns events before position N.
Constructors
| Edit this page View SourceSyncService(IDbContextFactory<ServerDbContext>, ServerStream, StateCache, TypingService, PushRuleService, PresenceService, TimeProvider)
Create the service.
Declaration
public SyncService(IDbContextFactory<ServerDbContext> contexts, ServerStream stream, StateCache cache, TypingService typing, PushRuleService pushRules, PresenceService presence, TimeProvider time)
Parameters
| Type | Name | Description |
|---|---|---|
| IDbContextFactory<ServerDbContext> | contexts | |
| ServerStream | stream | |
| StateCache | cache | |
| TypingService | typing | |
| PushRuleService | pushRules | |
| PresenceService | presence | |
| TimeProvider | time |
Methods
| Edit this page View SourceCreateFilterAsync(string, JsonObject, CancellationToken)
Store a filter of userId; return its ID.
Declaration
public Task<string> CreateFilterAsync(string userId, JsonObject filter, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| JsonObject | filter | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<string> |
GetContextAsync(Requester, string, string, int, SyncFilter, CancellationToken)
Return an event with events before and after it, and the state at it, for /context.
Declaration
public Task<JsonObject> GetContextAsync(Requester requester, string roomId, string eventId, int limit, SyncFilter filter, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Requester | requester | |
| string | roomId | |
| string | eventId | |
| int | limit | |
| SyncFilter | filter | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
GetEventAtAsync(Requester, string, long, bool, CancellationToken)
Return the event closest to timestamp in the direction asked, as timestamp_to_event answers; throw M_NOT_FOUND when there is none.
Declaration
public Task<JsonObject> GetEventAtAsync(Requester requester, string roomId, long timestamp, bool forwards, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Requester | requester | |
| string | roomId | |
| long | timestamp | |
| bool | forwards | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
GetFilterAsync(string, string, CancellationToken)
Return a stored filter's JSON; throw M_NOT_FOUND for unknown IDs.
Declaration
public Task<JsonObject> GetFilterAsync(string userId, string filterId, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| string | filterId | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
GetMessagesAsync(Requester, string, string?, string?, bool, int, SyncFilter, CancellationToken)
Return room history for /messages: events before from going backwards, or from it going forwards.
Declaration
public Task<JsonObject> GetMessagesAsync(Requester requester, string roomId, string? from, string? to, bool backwards, int limit, SyncFilter filter, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Requester | requester | |
| string | roomId | |
| string | from | |
| string | to | |
| bool | backwards | |
| int | limit | |
| SyncFilter | filter | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
GetRelationsAsync(Requester, string, string, string?, string?, string?, int, bool, CancellationToken)
Return the events that relate to eventId, such as edits, reactions and thread replies, as /relations answers; newest first unless forwards.
Declaration
public Task<JsonObject> GetRelationsAsync(Requester requester, string roomId, string eventId, string? relationType, string? eventType, string? from, int limit, bool forwards, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Requester | requester | Who asks; only events they can see are returned. |
| string | roomId | Room of the event. |
| string | eventId | Event related to. |
| string | relationType | Only this |
| string | eventType | Only this event type, or all. |
| string | from | Token to continue from, as |
| int | limit | Most events. |
| bool | forwards | Oldest first. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
GetThreadsAsync(Requester, string, bool, string?, int, CancellationToken)
Return the threads of a room: their root events with summaries, the most recently active first.
Declaration
public Task<JsonObject> GetThreadsAsync(Requester requester, string roomId, bool participated, string? from, int limit, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Requester | requester | Who asks; only roots they can see are listed. |
| string | roomId | Room. |
| bool | participated | Only threads the requester started or replied to. |
| string | from | Token to continue from, as |
| int | limit | Most threads. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
ParseToken(string)
Parse a token; throw M_INVALID_PARAM for others. Positions of history from other servers, such as a joined room's earlier state, are negative, so pagination tokens may be too.
Declaration
public static long ParseToken(string token)
Parameters
| Type | Name | Description |
|---|---|---|
| string | token |
Returns
| Type | Description |
|---|---|
| long |
ResolveFilterAsync(string, string?, CancellationToken)
Resolve a filter query parameter: inline JSON, a stored filter ID, or none.
Declaration
public Task<SyncFilter> ResolveFilterAsync(string userId, string? filter, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| string | filter | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<SyncFilter> |
SyncAsync(Requester, string?, TimeSpan, SyncFilter, bool, CancellationToken)
Return the sync response for requester, waiting up to timeout for something new after since.
Declaration
public Task<JsonObject> SyncAsync(Requester requester, string? since, TimeSpan timeout, SyncFilter filter, bool fullState, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Requester | requester | |
| string | since | |
| TimeSpan | timeout | |
| SyncFilter | filter | |
| bool | fullState | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
Token(long)
Format a stream position as a token.
Declaration
public static string Token(long position)
Parameters
| Type | Name | Description |
|---|---|---|
| long | position |
Returns
| Type | Description |
|---|---|
| string |