Class ToDeviceService
To-device messages between local devices, and the device_lists of sync.
Inherited Members
Namespace: Uniform.Matrix.Server.Encryption
Assembly: Uniform.Matrix.Server.dll
Syntax
public sealed class ToDeviceService
Remarks
A message waits until a sync from a token after it proves its device received it, so a lost response does not lose the message.
Constructors
| Edit this page View SourceToDeviceService(IDbContextFactory<ServerDbContext>, ServerStream, IOptions<ServerOptions>)
Create the service.
Declaration
public ToDeviceService(IDbContextFactory<ServerDbContext> contexts, ServerStream stream, IOptions<ServerOptions> options)
Parameters
| Type | Name | Description |
|---|---|---|
| IDbContextFactory<ServerDbContext> | contexts | |
| ServerStream | stream | |
| IOptions<ServerOptions> | options |
Methods
| Edit this page View SourceGetDeviceListsAsync(ServerDbContext, string, long, long, CancellationToken)
Return the users whose keys a client should fetch again (changed) or may forget (left) after since.
Declaration
public static Task<(IReadOnlyList<string> Changed, IReadOnlyList<string> Left)> GetDeviceListsAsync(ServerDbContext dbContext, string userId, long since, long until, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| ServerDbContext | dbContext | |
| string | userId | |
| long | since | |
| long | until | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<(IReadOnlyList<string> Changed, IReadOnlyList<string> Left)> |
Remarks
Changed: users sharing a room whose keys changed, users who joined a shared room, members of rooms the user joined, and the user. Left: users who left a shared room or whose room the user left, and who share no room any more.
SendAsync(Requester, string, string, JsonObject, CancellationToken)
Queue messages by user ID, then device ID or * for all devices; a retried transaction is not sent twice.
Declaration
public Task SendAsync(Requester requester, string type, string transactionId, JsonObject messages, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Requester | requester | |
| string | type | |
| string | transactionId | |
| JsonObject | messages | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
TakeAsync(ServerDbContext, string, string, long?, long, CancellationToken)
Return the device's messages up to until, first deleting those delivered before since.
Declaration
public static Task<IReadOnlyList<JsonObject>> TakeAsync(ServerDbContext dbContext, string userId, string deviceId, long? since, long until, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| ServerDbContext | dbContext | |
| string | userId | |
| string | deviceId | |
| long? | since | |
| long | until | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<IReadOnlyList<JsonObject>> |