Matrix.Sdk 0.0.1

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
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.9 110 3/13/2024
1.0.8 905 3/16/2023
1.0.7 1,889 11/7/2022
1.0.6 629 10/27/2022
1.0.5 1,336 10/13/2022
1.0.4 822 10/8/2022
1.0.3 1,182 8/30/2022
1.0.2 599 8/30/2022
1.0.1 376 8/29/2022
1.0.0 640 8/26/2022
0.0.7 1,338 1/20/2022
0.0.6 412 1/19/2022
0.0.5 390 12/13/2021
0.0.4 1,068 12/3/2021
0.0.3 389 11/19/2021
0.0.2 323 11/18/2021
0.0.1 348 11/18/2021