Class LiveKitSignalClient
LiveKit's signalling: a WebSocket to the server's /rtc, with protobuf SignalRequest messages out and SignalResponse messages in, and the pings that keep it open.
Implements
Inherited Members
Namespace: Uniform.LiveKit
Assembly: Uniform.LiveKit.dll
Syntax
public sealed class LiveKitSignalClient : IAsyncDisposable
Remarks
It joins with two peer connections, as LiveKit's clients did before the single one: the server offers the subscriber's, and this side offers the publisher's.
Fields
| Edit this page View SourceProtocolVersion
The signalling protocol this client speaks: the server's offers and answers, and trickled candidates, of two peer connections.
Declaration
public const int ProtocolVersion = 16
Field Value
| Type | Description |
|---|---|
| int |
Properties
| Edit this page View SourceJoin
What the server said on joining: the room, this participant, the others, and the ICE servers.
Declaration
public JoinResponse Join { get; }
Property Value
| Type | Description |
|---|---|
| JoinResponse |
RoundTrip
The round trip of the last ping, as the server's pong measured it.
Declaration
public TimeSpan RoundTrip { get; }
Property Value
| Type | Description |
|---|---|
| TimeSpan |
Methods
| Edit this page View SourceConnectAsync(string, string, ILogger?, bool, CancellationToken)
Connect to the server at url with token, and return the client once the server answered the join; it reads the messages after it from Start() on, so that none is missed.
Declaration
public static Task<LiveKitSignalClient> ConnectAsync(string url, string token, ILogger? logger = null, bool autoSubscribe = true, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | url | |
| string | token | |
| ILogger | logger | |
| bool | autoSubscribe | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<LiveKitSignalClient> |
Exceptions
| Type | Condition |
|---|---|
| WebSocketException | When the server cannot be reached, or refuses the token. |
| InvalidDataException | When the server's first message is not a join, e.g. a leave. |
DisposeAsync()
Tell the server this participant leaves, and close the socket.
Declaration
public ValueTask DisposeAsync()
Returns
| Type | Description |
|---|---|
| ValueTask |
RtcUrl(string, string, bool)
Return the URL of the server's signalling for url, the server's ws:// or wss:// URL, with the token and this client's options.
Declaration
public static Uri RtcUrl(string url, string token, bool autoSubscribe = true)
Parameters
| Type | Name | Description |
|---|---|---|
| string | url | |
| string | token | |
| bool | autoSubscribe |
Returns
| Type | Description |
|---|---|
| Uri |
SendAsync(SignalRequest, CancellationToken)
Send a message to the server; nothing after closing.
Declaration
public Task SendAsync(SignalRequest request, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| SignalRequest | request | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
Start()
Start reading the server's messages into MessageReceived, and pinging; once, after the handlers are added.
Declaration
public void Start()
Events
| Edit this page View SourceClosed
Raised once when the socket closed, by either side or by failing; on the receiving loop.
Declaration
public event Action? Closed
Event Type
| Type | Description |
|---|---|
| Action |
MessageReceived
Raised for each message of the server after the join, on the receiving loop.
Declaration
public event Action<SignalResponse>? MessageReceived
Event Type
| Type | Description |
|---|---|
| Action<SignalResponse> |