Livekitex.RoomService (livekitex v0.1.0)

Provides functionality to interact with the LiveKit RoomService API using Twirp.

Summary

Types

t()

@type t() :: %Livekitex.RoomService{
  api_key: String.t(),
  api_secret: String.t(),
  client: Tesla.Client.t() | nil,
  host: String.t(),
  port: integer()
}

Functions

create(api_key, api_secret, options \\ [])

Creates a new RoomService client.

Parameters

  • api_key: The API key for your LiveKit project.
  • api_secret: The API secret for your LiveKit project.
  • options: A keyword list of options.
    • host: The host of the LiveKit server. Defaults to "localhost".
    • port: The port of the LiveKit server. Defaults to 7880.

Examples

iex> Livekitex.RoomService.create("api_key", "api_secret")
%Livekitex.RoomService{
  api_key: "api_key",
  api_secret: "api_secret",
  host: "localhost",
  port: 7880
}

create_room(room_service, name, options \\ [])

Creates a new room.

Parameters

  • room_service: The RoomService client.
  • name: The name of the room.
  • options: A keyword list of options.
    • empty_timeout: Room timeout when empty (seconds)
    • departure_timeout: Timeout after participant departure (seconds)
    • max_participants: Maximum number of participants
    • metadata: Room metadata
    • min_playout_delay: Minimum playout delay (ms)
    • max_playout_delay: Maximum playout delay (ms)
    • sync_streams: Whether to sync streams

Examples

iex> room_service = Livekitex.RoomService.create("devkey", "secret")
iex> Livekitex.RoomService.create_room(room_service, "test-room")
{:ok, %Livekitex.Room{}}

delete_room(room_service, room_name)

Deletes a room.

Parameters

  • room_service: The RoomService client.
  • room_name: The name of the room to delete.

Examples

iex> room_service = Livekitex.RoomService.create("devkey", "secret")
iex> Livekitex.RoomService.delete_room(room_service, "test-room")
:ok

list_participants(room_service, room_name)

Lists participants in a room.

Parameters

  • room_service: The RoomService client.
  • room_name: The name of the room.

Examples

iex> room_service = Livekitex.RoomService.create("devkey", "secret")
iex> Livekitex.RoomService.list_participants(room_service, "test-room")
{:ok, []}

list_rooms(room_service, options \\ [])

Lists all rooms.

Parameters

  • room_service: The RoomService client.
  • options: A keyword list of options.
    • names: List of specific room names to filter by

Examples

iex> room_service = Livekitex.RoomService.create("devkey", "secret")
iex> Livekitex.RoomService.list_rooms(room_service)
{:ok, []}

mute_published_track(room_service, room_name, identity, track_sid, muted)

Mutes or unmutes a published track.

Parameters

  • room_service: The RoomService client.
  • room_name: The name of the room.
  • identity: The identity of the participant.
  • track_sid: The SID of the track to mute/unmute.
  • muted: Whether to mute (true) or unmute (false) the track.

Examples

iex> room_service = Livekitex.RoomService.create("devkey", "secret")
iex> Livekitex.RoomService.mute_published_track(room_service, "test-room", "user123", "track_sid", true)
{:ok, %{}}

remove_participant(room_service, room_name, identity)

Removes a participant from a room.

Parameters

  • room_service: The RoomService client.
  • room_name: The name of the room.
  • identity: The identity of the participant to remove.

Examples

iex> room_service = Livekitex.RoomService.create("devkey", "secret")
iex> Livekitex.RoomService.remove_participant(room_service, "test-room", "user123")
:ok