Table of Contents

Class LocalParticipant

Namespace
LiveKit.Rtc
Assembly
LivekitRtc.dll

Represents the local participant in the room.

public class LocalParticipant : Participant
Inheritance
LocalParticipant
Inherited Members

Methods

EditChatMessageAsync(string, ChatMessage, string[]?, string?)

Edits a previously sent chat message.

public Task<ChatMessage> EditChatMessageAsync(string editText, ChatMessage originalMessage, string[]? destinationIdentities = null, string? senderIdentity = null)

Parameters

editText string

The new text for the message.

originalMessage ChatMessage

The original message to edit.

destinationIdentities string[]

Optional array of destination participant identities.

senderIdentity string

Optional sender identity override.

Returns

Task<ChatMessage>

The edited chat message.

PerformRpcAsync(string, string, string, double?)

Performs an RPC call to a remote participant.

public Task<string> PerformRpcAsync(string destinationIdentity, string method, string payload, double? responseTimeout = null)

Parameters

destinationIdentity string

The identity of the destination participant.

method string

The RPC method name to call.

payload string

The payload to send with the request.

responseTimeout double?

Seconds to wait for the response; 15 when null.

Returns

Task<string>

The response payload from the remote participant.

Exceptions

RpcError

Thrown when the RPC call fails.

PublishDataAsync(byte[], DataPublishOptions?)

Publishes data to the room.

public Task PublishDataAsync(byte[] data, DataPublishOptions? options = null)

Parameters

data byte[]

The data to publish.

options DataPublishOptions

Publish options.

Returns

Task

A task that completes once the data has been sent.

PublishDataTrackAsync(string, CancellationToken)

Publishes a data track. Push frames on the returned track with TryPush(DataTrackFrame); remote participants receive it through DataTrackPublished.

public Task<LocalDataTrack> PublishDataTrackAsync(string name, CancellationToken cancellationToken = default)

Parameters

name string

The track name, used by other participants to identify it. Must not be empty and must be unique per publisher.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<LocalDataTrack>

The published data track.

Exceptions

PublishDataTrackException

The track could not be published.

PublishSipDtmfAsync(uint, string, string[]?)

Publishes SIP DTMF (Dual-Tone Multi-Frequency) tones to the room.

public Task PublishSipDtmfAsync(uint code, string digit, string[]? destinationIdentities = null)

Parameters

code uint

The DTMF code.

digit string

The DTMF digit as a string.

destinationIdentities string[]

Optional destination participant identities.

Returns

Task

A task that completes once the tones have been sent.

PublishTrackAsync(LocalTrack, TrackPublishOptions?, CancellationToken)

Publishes a track to the room.

public Task<LocalTrackPublication> PublishTrackAsync(LocalTrack track, TrackPublishOptions? options = null, CancellationToken cancellationToken = default)

Parameters

track LocalTrack

The track to publish.

options TrackPublishOptions

Publication options.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<LocalTrackPublication>

The track publication.

PublishTranscriptionAsync(Transcription)

Publishes transcription data to the room.

public Task PublishTranscriptionAsync(Transcription transcription)

Parameters

transcription Transcription

The transcription to publish.

Returns

Task

A task that completes once the transcription has been sent.

RegisterRpcMethod(string, RpcMethodHandler)

Registers a handler for incoming RPC method calls. Replaces any existing handler for the same method name.

public void RegisterRpcMethod(string method, RpcMethodHandler handler)

Parameters

method string

The RPC method name to handle.

handler RpcMethodHandler

The handler function to invoke when this method is called.

Remarks

The handler should return a string response or throw an RpcError. Other exceptions will be converted to ApplicationError responses.

SendChatMessageAsync(string, string[]?, string?)

Sends a chat message to participants in the room.

public Task<ChatMessage> SendChatMessageAsync(string message, string[]? destinationIdentities = null, string? senderIdentity = null)

Parameters

message string

The message text to send.

destinationIdentities string[]

Optional array of destination participant identities. If null, broadcasts to all.

senderIdentity string

Optional sender identity override.

Returns

Task<ChatMessage>

The sent chat message.

SendFileAsync(string, string?, string?, Dictionary<string, string>?, string[]?, string?)

Sends a file to participants in the room.

public Task<ByteStreamInfo> SendFileAsync(string filePath, string? topic = null, string? mimeType = null, Dictionary<string, string>? attributes = null, string[]? destinationIdentities = null, string? streamId = null)

Parameters

filePath string

The path to the file to send.

topic string

Optional topic for the file.

mimeType string

Optional MIME type (auto-detected if not provided).

attributes Dictionary<string, string>

Optional attributes.

destinationIdentities string[]

Optional destination participant identities.

streamId string

Optional custom stream ID.

Returns

Task<ByteStreamInfo>

The byte stream info.

SendTextAsync(string, string?, Dictionary<string, string>?, string[]?, string?)

Sends text to participants in the room.

public Task<TextStreamInfo> SendTextAsync(string text, string? topic = null, Dictionary<string, string>? attributes = null, string[]? destinationIdentities = null, string? streamId = null)

Parameters

text string

The text to send.

topic string

Optional topic for the message.

attributes Dictionary<string, string>

Optional attributes.

destinationIdentities string[]

Optional destination participant identities.

streamId string

Optional custom stream ID.

Returns

Task<TextStreamInfo>

The text stream info.

SetAttributesAsync(Dictionary<string, string>)

Sets custom attributes for the local participant.

public Task SetAttributesAsync(Dictionary<string, string> attributes)

Parameters

attributes Dictionary<string, string>

The attributes to set.

Returns

Task

A task that completes once the update has been sent.

Remarks

This requires canUpdateOwnMetadata permission. Existing attributes that are not overridden will remain unchanged.

SetDataChannelBufferedAmountLowThreshold(ulong, DataPacketKind)

Sets the buffered-amount-low threshold of the lossy or reliable data channel. The room raises DataChannelBufferedAmountLowThresholdChanged once applied.

public void SetDataChannelBufferedAmountLowThreshold(ulong threshold, DataPacketKind kind)

Parameters

threshold ulong

The new threshold in bytes.

kind DataPacketKind

The data channel to configure.

SetMetadataAsync(string)

Sets the local participant's metadata.

public Task SetMetadataAsync(string metadata)

Parameters

metadata string

The new metadata.

Returns

Task

A task that completes once the update has been sent.

SetNameAsync(string)

Sets the local participant's name.

public Task SetNameAsync(string name)

Parameters

name string

The new name.

Returns

Task

A task that completes once the update has been sent.

SetTrackSubscriptionPermissions(bool, ParticipantTrackPermission[]?)

Sets track subscription permissions for this local participant.

public void SetTrackSubscriptionPermissions(bool allParticipantsAllowed, ParticipantTrackPermission[]? participantPermissions = null)

Parameters

allParticipantsAllowed bool

Whether all participants are allowed to subscribe.

participantPermissions ParticipantTrackPermission[]

Specific permissions for individual participants.

StreamBytesAsync(string, string?, string?, Dictionary<string, string>?, string[]?, string?, string?, long?)

Streams bytes incrementally to participants in the room.

public Task<ByteStreamWriter> StreamBytesAsync(string name, string? topic = null, string? mimeType = null, Dictionary<string, string>? attributes = null, string[]? destinationIdentities = null, string? streamId = null, string? senderIdentity = null, long? totalSize = null)

Parameters

name string

The stream name (e.g., filename).

topic string

Optional topic for the stream.

mimeType string

MIME type (default: application/octet-stream).

attributes Dictionary<string, string>

Optional attributes for the stream.

destinationIdentities string[]

Optional destination participant identities.

streamId string

Optional custom stream ID.

senderIdentity string

Optional sender identity override.

totalSize long?

Optional total size hint.

Returns

Task<ByteStreamWriter>

A byte stream writer for sending byte chunks.

StreamTextAsync(string?, Dictionary<string, string>?, string[]?, string?, string?, long?)

Streams text incrementally to participants in the room.

public Task<TextStreamWriter> StreamTextAsync(string? topic = null, Dictionary<string, string>? attributes = null, string[]? destinationIdentities = null, string? streamId = null, string? senderIdentity = null, long? totalSize = null)

Parameters

topic string

Optional topic for the stream.

attributes Dictionary<string, string>

Optional attributes for the stream.

destinationIdentities string[]

Optional destination participant identities.

streamId string

Optional custom stream ID (auto-generated if not provided).

senderIdentity string

Optional sender identity override.

totalSize long?

Optional total size hint.

Returns

Task<TextStreamWriter>

A text stream writer for sending text chunks.

UnpublishTrackAsync(string, CancellationToken)

Unpublishes a track from the room.

public Task UnpublishTrackAsync(string trackSid, CancellationToken cancellationToken = default)

Parameters

trackSid string

The SID of the track to unpublish.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

A task that completes once the track is unpublished.

UnregisterRpcMethod(string)

Unregisters a previously registered RPC method handler.

public void UnregisterRpcMethod(string method)

Parameters

method string

The RPC method name to unregister.