Matrix.Sdk 0.0.1

.NET 5.0
There is a newer version of this package available.
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
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Matrix.Sdk" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Matrix.Sdk --version 0.0.1
#r "nuget: Matrix.Sdk, 0.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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

matrix-logo

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
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

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.8 63 3/16/2023
1.0.7 1,113 11/7/2022
1.0.6 457 10/27/2022
1.0.5 786 10/13/2022
1.0.4 568 10/8/2022
1.0.3 888 8/30/2022
1.0.2 430 8/30/2022
1.0.1 259 8/29/2022
1.0.0 454 8/26/2022
0.0.7 986 1/20/2022
0.0.6 303 1/19/2022
0.0.5 269 12/13/2021
0.0.4 917 12/3/2021
0.0.3 288 11/19/2021
0.0.2 246 11/18/2021
0.0.1 249 11/18/2021