Uniform.Matrix.Protocol.Client
0.1.2
dotnet add package Uniform.Matrix.Protocol.Client --version 0.1.2
NuGet\Install-Package Uniform.Matrix.Protocol.Client -Version 0.1.2
<PackageReference Include="Uniform.Matrix.Protocol.Client" Version="0.1.2" />
<PackageVersion Include="Uniform.Matrix.Protocol.Client" Version="0.1.2" />
<PackageReference Include="Uniform.Matrix.Protocol.Client" />
paket add Uniform.Matrix.Protocol.Client --version 0.1.2
#r "nuget: Uniform.Matrix.Protocol.Client, 0.1.2"
#:package Uniform.Matrix.Protocol.Client@0.1.2
#addin nuget:?package=Uniform.Matrix.Protocol.Client&version=0.1.2
#tool nuget:?package=Uniform.Matrix.Protocol.Client&version=0.1.2
Uniform.Matrix.Protocol.Client
An HTTP client of the Matrix Client-Server API: discovery, login and registration, sync, rooms and messages, media, devices, end-to-end encryption keys and key backup.
dotnet add package Uniform.Matrix.Protocol.Client
Log in
using Uniform.Matrix.Protocol.Client;
using Uniform.Matrix.Protocol.Core;
using HttpClient http = new();
// Find the homeserver for the server part of the user ID
UserId userId = UserId.Parse("@alice:matrix.org");
Uri homeserver = await HomeserverDiscovery.DiscoverAsync(http, userId.ServerName);
MatrixClient client = new(http, homeserver);
await client.LoginWithPasswordAsync(userId.ToString(), password, deviceDisplayName: "My app");
Store client.Session to resume later without the password: new MatrixClient(http, session).
Receive and send messages
await foreach (SyncResponse sync in client.SyncLoopAsync(cancellationToken: cancellationToken))
{
foreach ((string roomId, JoinedRoom room) in sync.Rooms.Join)
{
foreach (ClientEvent clientEvent in room.Timeline.Events)
{
if (clientEvent.Type != EventTypes.RoomMessage || !clientEvent.TryGetContent(out MessageContent? message)) continue;
Console.WriteLine($"[{roomId}] {clientEvent.Sender}: {message.Body}");
}
}
}
string roomId = await client.JoinRoomAsync("#lobby:matrix.org");
await client.SendEventAsync(roomId, EventTypes.RoomMessage, new MessageContent { MessageType = MessageTypes.Text, Body = "Hello" });
SyncLoopAsync long-polls and retries network errors with backoff; store NextBatch with the session and pass it as since to continue where you left off.
Notes
- One
MatrixClientserves one homeserver and one session. The caller owns theHttpClient, so it works withIHttpClientFactory; keep its timeout longer than the sync long-poll. - Rate-limited requests are retried after the server's
retry_after_ms; other errors throwMatrixException. - Endpoints that need user-interactive auth, such as deleting devices, take the password and answer the server's challenge.
- For end-to-end encryption, see Uniform.Matrix.Protocol.Crypto; for a client with local storage and room state, Uniform.Matrix.Client.
More in Using the protocol client.
About
Part of Uniform.Matrix, a pure .NET implementation of the Matrix specification. Version 0.1 is an early pre-release: APIs may still change.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Uniform.Matrix.Protocol.Core (>= 0.1.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Uniform.Matrix.Protocol.Client:
| Package | Downloads |
|---|---|
|
Uniform.Matrix.Client
Matrix client engine with local SQLite storage: session, sync, outbox, media cache, encryption and room state. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.2 | 0 | 10/27/2026 |
| 0.1.0 | 28 | 10/26/2026 |
| 0.1.0-alpha.1 | 31 | 10/26/2026 |