Livekit.Client 0.1.2

dotnet add package Livekit.Client --version 0.1.2
                    
NuGet\Install-Package Livekit.Client -Version 0.1.2
                    
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="Livekit.Client" Version="0.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Livekit.Client" Version="0.1.2" />
                    
Directory.Packages.props
<PackageReference Include="Livekit.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Livekit.Client --version 0.1.2
                    
#r "nuget: Livekit.Client, 0.1.2"
                    
#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.
#:package Livekit.Client@0.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Livekit.Client&version=0.1.2
                    
Install as a Cake Addin
#tool nuget:?package=Livekit.Client&version=0.1.2
                    
Install as a Cake Tool

Livekit .NET Server SDK

C# Server SDK for the Livekit project (https://github.com/livekit).

Only works with custom livekit build, using an extra grpc service (currently as forked project: https://github.com/sze-plusplusplus/livekit-server)

Docker image for the custom build: docker pull ghcr.io/bencebaranyai/livekit-server:latest

Protocol SDK
0.9.4 0.1.1
0.10.2 0.1.2

Protocol: https://github.com/livekit/protocol


Install

Package: https://www.nuget.org/packages/Livekit.Client/

Install-Package Livekit.Client -Version 0.1.2

or

dotnet add package Livekit.Client --version 0.1.2

Usage

Similar to JS SDK (https://github.com/livekit/server-sdk-js)

Example app

Livekit.Client.Example/

cd Livekit.Client.Example/
cp appsettings.example.json appsettings.json
docker-compose up

A livekit server and an example container will be started. Example app has a webhook endpoint, write out the incoming requests, will create a new join token, list the rooms periodically

The displayed token can be used to join on the example page of livekit server: https://example.livekit.io (LiveKit URL: default [ws://localhost:7880])

Creating Access Tokens

var ac = new AccessToken("<key>", "<secret>", new Grant()
            {
                video = new VideoGrant()
                {
                    roomJoin = true,
                    room = "Room Name"
                }
            }, "Username");
System.Console.WriteLine(ac.GetToken());
System.Console.WriteLine(ac.GetAsHeader());
System.Console.WriteLine(ac.VerifyToken("<webhook token to verify>")); // returns the "sha256" claim if otherwise the token is valid

Room Service Client

// host: "http://<hostname>:<grpc_port_of_livekit>"
var room = new RoomClient("<host>", "<key>", "<secret>");

var room = room.CreateRoom("TestRoom");
System.Console.WriteLine(r.Name); // Properties can be accessed

var users = room.ListParticipants("TestRoom");
...

Recording Service Client

Requires Redis and recording instance of livekit

var rs = new RecordingClient("<host>", "<key>", "<secret>");
var id = rc.StartRecording(new Proto.RecordingTemplate(){
    RoomName = "TestRoom"
});
rc.EndRecording(id);

Receive webhook requests

The SDK does not contains a webserver/webservice. Simple example is added to the Example project.

... // "context" is a HttpContext variable
var receiver = new WebhookReceiver("<key>", "<secret>");
var jwt = context.Request.Headers[WebhookReceiver.AuthHeader];
var request = receiver.Receive("body string from context...", jwt); // skipAuth can be toggled
// if the checksum does not match, Receive will throw an Exception

if (r.Event == WebhookEvents.PARTICIPANT_JOINED)
{
    System.Console.WriteLine("{0} entered the room!", r.Participant.Identity);
}
...

Tested

  • Ubuntu 20.04/dotnet 5.0 - Livekit server 0.13.0

License

Apache license 2.0

See LICENSE

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.2 2,227 11/28/2021
0.1.1 500 9/28/2021
0.1.0 386 9/28/2021