Matrix.Sdk
0.0.1
See the version list below for details.
dotnet add package Matrix.Sdk --version 0.0.1
NuGet\Install-Package Matrix.Sdk -Version 0.0.1
<PackageReference Include="Matrix.Sdk" Version="0.0.1" />
paket add Matrix.Sdk --version 0.0.1
#r "nuget: Matrix.Sdk, 0.0.1"
// Install Matrix.Sdk as a Cake Addin #addin nuget:?package=Matrix.Sdk&version=0.0.1 // Install Matrix.Sdk as a Cake Tool #tool nuget:?package=Matrix.Sdk&version=0.0.1
Matrix .NET SDK
This open-source library allows you to build .NET apps compatible with Matrix Protocol. It has support for a limited subset of the APIs presently.
This SDK was built for interaction with the Beacon Node. It supports login through the crypto_auth_provider.py
.
Use the SDK in your app
For a complete example, refer to SimpleExample.cs
.
You can also clone this repository and run Matrix.Sdk.Sample.Console
.
Here is step by step guide:
1. Create
Use MatrixClientFactory to create an instance of MatrixClient
var factory = new MatrixClientFactory();
IMatrixClient client = factory.Create();
2. Login
Currently, MatrixClient
supports only password login.
await client.LoginAsync(matrixNodeAddress, username, password, deviceId);
3. Start listening for incoming events
To listen for the incoming Matrix room events you need to subscribe to OnMatrixRoomEventsReceived;
client.OnMatrixRoomEventsReceived += (sender, eventArgs) =>
{
foreach (BaseRoomEvent roomEvent in eventArgs.MatrixRoomEvents)
{
if (roomEvent is not TextMessageEvent textMessageEvent)
continue;
(string roomId, string senderUserId, string message) = textMessageEvent;
if (client.UserId != senderUserId)
Console.WriteLine($"RoomId: {roomId} received message from {senderUserId}: {message}.");
}
};
I recommend that you don't use anonymous functions to subscribe to events if you have to unsubscribe from the event at some later point in your code.
Then you should start MatrixClient
client.Start();
If you need to stop listening, for example, when the app is suspended, then do the following
client.Stop();
4. Basic functions
// Create room
MatrixRoom matrixRoom = await client.CreateTrustedPrivateRoomAsync(new[]
{
anotherClient.UserId
});
// Join room
await anotherClient.JoinTrustedPrivateRoomAsync(matrixRoom.Id);
// Send message
await client.SendMessageAsync(matrixRoom.Id, "some message");
//Get joined rooms ids
await client.GetJoinedRoomsIdsAsync();
// Leave room
await client.LeaveRoomAsync(roomId);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net5.0
- Microsoft.Extensions.Http (>= 5.0.0)
- Newtonsoft.Json (>= 13.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Matrix.Sdk:
Package | Downloads |
---|---|
Beacon.Sdk
Beacon .NET SDK for Tezos wallet / dApps developers. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.9 | 337 | 3/13/2024 |
1.0.8 | 1,093 | 3/16/2023 |
1.0.7 | 2,027 | 11/7/2022 |
1.0.6 | 669 | 10/27/2022 |
1.0.5 | 1,471 | 10/13/2022 |
1.0.4 | 859 | 10/8/2022 |
1.0.3 | 1,247 | 8/30/2022 |
1.0.2 | 641 | 8/30/2022 |
1.0.1 | 388 | 8/29/2022 |
1.0.0 | 669 | 8/26/2022 |
0.0.7 | 1,396 | 1/20/2022 |
0.0.6 | 421 | 1/19/2022 |
0.0.5 | 425 | 12/13/2021 |
0.0.4 | 1,124 | 12/3/2021 |
0.0.3 | 430 | 11/19/2021 |
0.0.2 | 347 | 11/18/2021 |
0.0.1 | 376 | 11/18/2021 |