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
See Room service API.
Constructors
RoomServiceClient(string, string, string, HttpClient)
Creates the client.
public RoomServiceClient(string host, string apiKey = null, string apiSecret = null, HttpClient client = null)
Parameters
hoststringURL of the LiveKit server,
http(s)://orws(s)://; a subpath such ashttps://host/livekitis kept.apiKeystringAPI key; the
LIVEKIT_API_KEYenvironment variable when omitted.apiSecretstringAPI secret; the
LIVEKIT_API_SECRETenvironment variable when omitted.clientHttpClientOptional 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
requestCreateRoomRequestRoom settings: name (required), empty timeout, maximum participants, metadata, egress...
Returns
DeleteRoom(DeleteRoomRequest)
Deletes a room.
public Task<DeleteRoomResponse> DeleteRoom(DeleteRoomRequest request)
Parameters
requestDeleteRoomRequestRoom 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
requestForwardParticipantRequestRoom 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
requestRoomParticipantIdentityRoom name and participant identity.
Returns
- Task<ParticipantInfo>
The participant.
ListParticipants(ListParticipantsRequest)
Lists participants in a room.
public Task<ListParticipantsResponse> ListParticipants(ListParticipantsRequest request)
Parameters
requestListParticipantsRequestRoom name.
Returns
- Task<ListParticipantsResponse>
The participants currently in the room.
ListRooms(ListRoomsRequest)
Lists active rooms.
public Task<ListRoomsResponse> ListRooms(ListRoomsRequest request)
Parameters
requestListRoomsRequestOptional 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
requestMoveParticipantRequestRoom 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
requestMuteRoomTrackRequestRoom 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
requestRoomParticipantIdentityRoom 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
requestSendDataRequestRoom 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
requestUpdateParticipantRequestRoom 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
requestUpdateRoomMetadataRequestRoom name and the new metadata.
Returns
UpdateSubscriptions(UpdateSubscriptionsRequest)
Updates a participant's subscription to tracks.
public Task<UpdateSubscriptionsResponse> UpdateSubscriptions(UpdateSubscriptionsRequest request)
Parameters
requestUpdateSubscriptionsRequestRoom name, participant identity, track SIDs and whether to subscribe or unsubscribe.
Returns
- Task<UpdateSubscriptionsResponse>
Empty response.