Table of Contents

Class RoomServiceClient

Namespace
Livekit.Server.Sdk.Dotnet
Assembly
LivekitApi.dll

Client of the LiveKit Room service: creates, lists and deletes rooms and manages their participants, tracks and data messages.

public class RoomServiceClient : BaseService
Inheritance
RoomServiceClient
Inherited Members

Examples

var client = new RoomServiceClient("https://my.livekit.instance", "api-key", "api-secret");

await client.CreateRoom(new CreateRoomRequest { Name = "my-room", EmptyTimeout = 300 });

var response = await client.ListParticipants(new ListParticipantsRequest { Room = "my-room" });
foreach (ParticipantInfo participant in response.Participants)
    Console.WriteLine(participant.Identity);

Remarks

Constructors

RoomServiceClient(string, string, string, HttpClient)

Creates the client.

public RoomServiceClient(string host, string apiKey = null, string apiSecret = null, HttpClient client = null)

Parameters

host string

URL of the LiveKit server, http(s):// or ws(s)://; a subpath such as https://host/livekit is kept.

apiKey string

API key; the LIVEKIT_API_KEY environment variable when omitted.

apiSecret string

API secret; the LIVEKIT_API_SECRET environment variable when omitted.

client HttpClient

Optional HttpClient to send the requests with. The SDK never modifies it, so it can be shared with other clients and code.

Methods

CreateRoom(CreateRoomRequest)

Creates a new room. Explicit room creation is not required, since rooms will be automatically created when the first participant joins. This method can be used to customize room settings.

public Task<Room> CreateRoom(CreateRoomRequest request)

Parameters

request CreateRoomRequest

Room settings: name (required), empty timeout, maximum participants, metadata, egress...

Returns

Task<Room>

The created room, or the existing room with that name.

DeleteRoom(DeleteRoomRequest)

Deletes a room.

public Task<DeleteRoomResponse> DeleteRoom(DeleteRoomRequest request)

Parameters

request DeleteRoomRequest

Room name.

Returns

Task<DeleteRoomResponse>

Empty response.

ForwardParticipant(ForwardParticipantRequest)

Forwards a participant's track(s) to another room. Requires RoomAdmin and DestinationRoom. This will create a participant to join the destination room that has same information with the source participant except the kind to be Forwarded. All changes to the source participant will be reflected to the forwarded participant. When the source participant disconnects or the RemoveParticipant method is called in the destination room, the forwarding will be stopped. A participant can be forwarded to multiple rooms. The destination room will be created if it does not exist.

public Task<ForwardParticipantResponse> ForwardParticipant(ForwardParticipantRequest request)

Parameters

request ForwardParticipantRequest

Room name, participant identity and the destination room.

Returns

Task<ForwardParticipantResponse>

Empty response.

GetParticipant(RoomParticipantIdentity)

Gets information on a specific participant, including the tracks that the participant has published.

public Task<ParticipantInfo> GetParticipant(RoomParticipantIdentity request)

Parameters

request RoomParticipantIdentity

Room name and participant identity.

Returns

Task<ParticipantInfo>

The participant.

ListParticipants(ListParticipantsRequest)

Lists participants in a room.

public Task<ListParticipantsResponse> ListParticipants(ListParticipantsRequest request)

Parameters

request ListParticipantsRequest

Room name.

Returns

Task<ListParticipantsResponse>

The participants currently in the room.

ListRooms(ListRoomsRequest)

Lists active rooms.

public Task<ListRoomsResponse> ListRooms(ListRoomsRequest request)

Parameters

request ListRoomsRequest

Optional room names to filter by.

Returns

Task<ListRoomsResponse>

The active rooms.

MoveParticipant(MoveParticipantRequest)

Move a connected participant to a different room. Requires RoomAdmin and DestinationRoom. The participant will be removed from the current room and added to the destination room. From other observers' perspective, the participant would've disconnected from the previous room and joined the new one.

public Task<MoveParticipantResponse> MoveParticipant(MoveParticipantRequest request)

Parameters

request MoveParticipantRequest

Room name, participant identity and the destination room.

Returns

Task<MoveParticipantResponse>

Empty response.

MutePublishedTrack(MuteRoomTrackRequest)

Mutes a track that a participant has published.

public Task<MuteRoomTrackResponse> MutePublishedTrack(MuteRoomTrackRequest request)

Parameters

request MuteRoomTrackRequest

Room name, participant identity, track SID and whether to mute or unmute.

Returns

Task<MuteRoomTrackResponse>

The updated track.

RemoveParticipant(RoomParticipantIdentity)

Removes a participant from a room. This will disconnect the participant and emit a Disconnected event for them. They can re-join the room later.

public Task<RemoveParticipantResponse> RemoveParticipant(RoomParticipantIdentity request)

Parameters

request RoomParticipantIdentity

Room name and participant identity.

Returns

Task<RemoveParticipantResponse>

Empty response.

SendData(SendDataRequest)

Sends a data message to participants in the room.

public Task<SendDataResponse> SendData(SendDataRequest request)

Parameters

request SendDataRequest

Room name, payload, delivery kind (reliable or lossy), destination identities and topic. The SDK adds the nonce.

Returns

Task<SendDataResponse>

Empty response.

UpdateParticipant(UpdateParticipantRequest)

Updates a participant's metadata or permissions.

public Task<ParticipantInfo> UpdateParticipant(UpdateParticipantRequest request)

Parameters

request UpdateParticipantRequest

Room name, participant identity and the new metadata, permissions, name or attributes.

Returns

Task<ParticipantInfo>

The updated participant.

UpdateRoomMetadata(UpdateRoomMetadataRequest)

Updates metadata of a room.

public Task<Room> UpdateRoomMetadata(UpdateRoomMetadataRequest request)

Parameters

request UpdateRoomMetadataRequest

Room name and the new metadata.

Returns

Task<Room>

The updated room.

UpdateSubscriptions(UpdateSubscriptionsRequest)

Updates a participant's subscription to tracks.

public Task<UpdateSubscriptionsResponse> UpdateSubscriptions(UpdateSubscriptionsRequest request)

Parameters

request UpdateSubscriptionsRequest

Room name, participant identity, track SIDs and whether to subscribe or unsubscribe.

Returns

Task<UpdateSubscriptionsResponse>

Empty response.