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
editTextstringThe new text for the message.
originalMessageChatMessageThe original message to edit.
destinationIdentitiesstring[]Optional array of destination participant identities.
senderIdentitystringOptional 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
destinationIdentitystringThe identity of the destination participant.
methodstringThe RPC method name to call.
payloadstringThe payload to send with the request.
responseTimeoutdouble?Seconds to wait for the response; 15 when null.
Returns
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
databyte[]The data to publish.
optionsDataPublishOptionsPublish 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
namestringThe track name, used by other participants to identify it. Must not be empty and must be unique per publisher.
cancellationTokenCancellationTokenCancellation 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
codeuintThe DTMF code.
digitstringThe DTMF digit as a string.
destinationIdentitiesstring[]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
trackLocalTrackThe track to publish.
optionsTrackPublishOptionsPublication options.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<LocalTrackPublication>
The track publication.
PublishTranscriptionAsync(Transcription)
Publishes transcription data to the room.
public Task PublishTranscriptionAsync(Transcription transcription)
Parameters
transcriptionTranscriptionThe 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
methodstringThe RPC method name to handle.
handlerRpcMethodHandlerThe 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
messagestringThe message text to send.
destinationIdentitiesstring[]Optional array of destination participant identities. If null, broadcasts to all.
senderIdentitystringOptional 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
filePathstringThe path to the file to send.
topicstringOptional topic for the file.
mimeTypestringOptional MIME type (auto-detected if not provided).
attributesDictionary<string, string>Optional attributes.
destinationIdentitiesstring[]Optional destination participant identities.
streamIdstringOptional 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
textstringThe text to send.
topicstringOptional topic for the message.
attributesDictionary<string, string>Optional attributes.
destinationIdentitiesstring[]Optional destination participant identities.
streamIdstringOptional 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
attributesDictionary<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
thresholdulongThe new threshold in bytes.
kindDataPacketKindThe data channel to configure.
SetMetadataAsync(string)
Sets the local participant's metadata.
public Task SetMetadataAsync(string metadata)
Parameters
metadatastringThe 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
namestringThe 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
allParticipantsAllowedboolWhether all participants are allowed to subscribe.
participantPermissionsParticipantTrackPermission[]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
namestringThe stream name (e.g., filename).
topicstringOptional topic for the stream.
mimeTypestringMIME type (default: application/octet-stream).
attributesDictionary<string, string>Optional attributes for the stream.
destinationIdentitiesstring[]Optional destination participant identities.
streamIdstringOptional custom stream ID.
senderIdentitystringOptional sender identity override.
totalSizelong?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
topicstringOptional topic for the stream.
attributesDictionary<string, string>Optional attributes for the stream.
destinationIdentitiesstring[]Optional destination participant identities.
streamIdstringOptional custom stream ID (auto-generated if not provided).
senderIdentitystringOptional sender identity override.
totalSizelong?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
trackSidstringThe SID of the track to unpublish.
cancellationTokenCancellationTokenCancellation 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
methodstringThe RPC method name to unregister.