Class LocalParticipant
- Namespace
- LiveKit
public sealed class LocalParticipant : Participant
- Inheritance
-
LocalParticipant
- Inherited Members
- Extension Methods
Properties
Tracks
public IReadOnlyDictionary<string, LocalTrackPublication> Tracks { get; }
Property Value
Methods
PerformRpc(PerformRpcParams)
Performs RPC on another participant in the room. This allows you to execute a custom method on a remote participant and await their response.
public PerformRpcInstruction PerformRpc(PerformRpcParams rpcParams)
Parameters
rpcParamsPerformRpcParamsParameters for the RPC call including: - DestinationIdentity: The identity of the participant to call - Method: Name of the method to call (up to 64 bytes UTF-8) - Payload: String payload (max 15KiB UTF-8) - ResponseTimeout: Maximum time to wait for response (defaults to 15 seconds) If a value less than 8 seconds is provided, it will be automatically clamped to 8 seconds to ensure sufficient time for round-trip latency buffering.
Returns
- PerformRpcInstruction
A PerformRpcInstruction that completes when the RPC call receives a response or errors. Check PerformRpcInstruction.IsError and access Payload/Error properties to handle the result.
Remarks
See https://docs.livekit.io/home/client/data/rpc/#errors for a list of possible error codes.
PublishData(byte[], IReadOnlyCollection<string>, bool, string)
public void PublishData(byte[] data, IReadOnlyCollection<string> destination_identities = null, bool reliable = true, string topic = null)
Parameters
databyte[]destination_identitiesIReadOnlyCollection<string>reliablebooltopicstring
PublishData(Span<byte>, IReadOnlyCollection<string>, bool, string)
public void PublishData(Span<byte> data, IReadOnlyCollection<string> destination_identities = null, bool reliable = true, string topic = null)
Parameters
PublishDataTrack(DataTrackOptions)
Publishes a data track.
public PublishDataTrackInstruction PublishDataTrack(DataTrackOptions options)
Parameters
optionsDataTrackOptionsOptions for the data track, including the track name.
Returns
- PublishDataTrackInstruction
A PublishDataTrackInstruction that completes when the track is published or errors. Check PublishDataTrackInstruction.IsError and access Track to get the published track. Use TryPush(DataTrackFrame) to send data frames on the track.
PublishDataTrack(string)
Publishes a data track.
public PublishDataTrackInstruction PublishDataTrack(string name)
Parameters
namestringThe track name used to identify the track to other participants. Must not be empty and must be unique per publisher.
Returns
- PublishDataTrackInstruction
A PublishDataTrackInstruction that completes when the track is published or errors. Check PublishDataTrackInstruction.IsError and access Track to get the published track. Use TryPush(DataTrackFrame) to send data frames on the track.
Remarks
Use the PublishDataTrack(DataTrackOptions) overload to set additional options.
PublishTrack(ILocalTrack, TrackPublishOptions)
public PublishTrackInstruction PublishTrack(ILocalTrack localTrack, TrackPublishOptions options)
Parameters
localTrackILocalTrackoptionsTrackPublishOptions
Returns
RegisterRpcMethod(string, RpcHandler)
Registers a new RPC method handler.
public void RegisterRpcMethod(string method, RpcHandler handler)
Parameters
methodstringThe name of the RPC method to register
handlerRpcHandlerThe async callback that handles incoming RPC requests. It receives an RpcInvocationData object containing the caller's identity, payload (up to 15KiB UTF-8), and response timeout. Must return a string response or throw an RpcError. Any other exceptions will be converted to a generic APPLICATION_ERROR (1500).
SendFile(string, StreamByteOptions)
Send a file on disk to participants in the room.
public SendFileInstruction SendFile(string path, StreamByteOptions options)
Parameters
pathstringPath to the file to be sent.
optionsStreamByteOptionsConfiguration options for the byte stream, including topic and destination participants.
Returns
- SendFileInstruction
A SendFileInstruction that completes when the file is sent or errors. Check SendFileInstruction.IsError and access Info properties to handle the result.
SendFile(string, string)
Send a file on disk to participants in the room.
public SendFileInstruction SendFile(string path, string topic)
Parameters
pathstringPath to the file to be sent.
topicstringTopic identifier used to route the stream to appropriate handlers.
Returns
- SendFileInstruction
A SendFileInstruction that completes when the file is sent or errors. Check SendFileInstruction.IsError and access Info properties to handle the result.
Remarks
Use the SendFile(string, StreamByteOptions) overload to set custom stream options.
SendText(string, StreamTextOptions)
Send text to participants in the room.
public SendTextInstruction SendText(string text, StreamTextOptions options)
Parameters
textstringThe text content to send.
optionsStreamTextOptionsConfiguration options for the text stream, including topic and destination participants.
Returns
- SendTextInstruction
A SendTextInstruction that completes when the text is sent or errors. Check SendTextInstruction.IsError and access Info properties to handle the result.
SendText(string, string)
Send text to participants in the room.
public SendTextInstruction SendText(string text, string topic)
Parameters
textstringThe text content to send.
topicstringTopic identifier used to route the stream to appropriate handlers.
Returns
- SendTextInstruction
A SendTextInstruction that completes when the text is sent or errors. Check SendTextInstruction.IsError and access Info properties to handle the result.
Remarks
Use the SendText(string, StreamTextOptions) overload to set custom stream options.
SetAttributes(IDictionary<string, string>)
Set custom attributes for the local participant.
public SetLocalAttributesInstruction SetAttributes(IDictionary<string, string> attributes)
Parameters
attributesIDictionary<string, string>The new attributes. Existing attributes that are not overridden will remain unchanged.
Returns
Remarks
This requires canUpdateOwnMetadata permission.
SetMetadata(string)
Set the metadata for the local participant.
public SetLocalMetadataInstruction SetMetadata(string metadata)
Parameters
metadatastringThe new metadata.
Returns
Remarks
This requires canUpdateOwnMetadata permission.
SetName(string)
Set the name for the local participant.
public SetLocalNameInstruction SetName(string name)
Parameters
namestringThe new name.
Returns
Remarks
This requires canUpdateOwnMetadata permission.
StreamBytes(StreamByteOptions)
Stream bytes incrementally to participants in the room.
public StreamBytesInstruction StreamBytes(StreamByteOptions options)
Parameters
optionsStreamByteOptionsConfiguration options for the byte stream, including topic and destination participants.
Returns
- StreamBytesInstruction
A StreamBytesInstruction that completes once the stream is open or errors. Check StreamBytesInstruction.IsError and access Writer to access the writer for the opened stream.
Remarks
This method allows sending byte data in chunks as it becomes available. Unlike SendFile(string, StreamByteOptions), which sends the entire file at once, this method allows using a writer to send byte data incrementally.
StreamBytes(string)
Stream bytes to participants in the room.
public StreamBytesInstruction StreamBytes(string topic)
Parameters
topicstringTopic identifier used to route the stream to appropriate handlers.
Returns
- StreamBytesInstruction
A StreamBytesInstruction that completes once the stream is open or errors. Check StreamBytesInstruction.IsError and access Writer to access the writer for the opened stream.
Remarks
Use the StreamBytes(StreamByteOptions) overload to set custom stream options.
StreamText(StreamTextOptions)
Stream text incrementally to participants in the room.
public StreamTextInstruction StreamText(StreamTextOptions options)
Parameters
optionsStreamTextOptionsConfiguration options for the text stream, including topic and destination participants.
Returns
- StreamTextInstruction
A StreamTextInstruction that completes once the stream is open or errors. Check StreamTextInstruction.IsError and access Writer to access the writer for the opened stream.
Remarks
This method allows sending text data in chunks as it becomes available. Unlike SendText(string, StreamTextOptions), which sends the entire text at once, this method allows using a writer to send text incrementally.
StreamText(string)
Stream text to participants in the room.
public StreamTextInstruction StreamText(string topic)
Parameters
topicstringTopic identifier used to route the stream to appropriate handlers.
Returns
- StreamTextInstruction
A StreamTextInstruction that completes once the stream is open or errors. Check StreamTextInstruction.IsError and access Writer to access the writer for the opened stream.
Remarks
Use the StreamText(StreamTextOptions) overload to set custom stream options.
UnpublishTrack(ILocalTrack, bool)
public UnpublishTrackInstruction UnpublishTrack(ILocalTrack localTrack, bool stopOnUnpublish)
Parameters
localTrackILocalTrackstopOnUnpublishbool
Returns
UnregisterRpcMethod(string)
Unregisters a previously registered RPC method handler.
public void UnregisterRpcMethod(string method)
Parameters
methodstringThe name of the RPC method to unregister
UpdateMetadata(string)
[Obsolete("Use SetMetadata instead")]
public void UpdateMetadata(string metadata)
Parameters
metadatastring
UpdateName(string)
[Obsolete("Use SetName instead")]
public void UpdateName(string name)
Parameters
namestring