Livekit.Client
0.1.2
dotnet add package Livekit.Client --version 0.1.2
NuGet\Install-Package Livekit.Client -Version 0.1.2
<PackageReference Include="Livekit.Client" Version="0.1.2" />
<PackageVersion Include="Livekit.Client" Version="0.1.2" />
<PackageReference Include="Livekit.Client" />
paket add Livekit.Client --version 0.1.2
#r "nuget: Livekit.Client, 0.1.2"
#:package Livekit.Client@0.1.2
#addin nuget:?package=Livekit.Client&version=0.1.2
#tool nuget:?package=Livekit.Client&version=0.1.2
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
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 | 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. 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. |
-
net5.0
- Google.Protobuf (>= 3.17.3)
- Grpc.Net.Client (>= 2.38.0)
- System.IdentityModel.Tokens.Jwt (>= 6.12.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.