Class: LiveKit::RoomServiceClient
- Inherits:
-
Twirp::Client
- Object
- Twirp::Client
- LiveKit::RoomServiceClient
- Includes:
- AuthMixin
- Defined in:
- lib/livekit/room_service_client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_secret ⇒ Object
Returns the value of attribute api_secret.
Instance Method Summary collapse
-
#create_room(name, empty_timeout: nil, max_participants: nil) ⇒ Object
creates a new room with name.
- #delete_room(room:) ⇒ Object
- #get_participant(room:, identity:) ⇒ Object
-
#initialize(base_url, api_key: nil, api_secret: nil) ⇒ RoomServiceClient
constructor
A new instance of RoomServiceClient.
- #list_participants(room:) ⇒ Object
-
#list_rooms(names: nil) ⇒ Object
Lists rooms, when names is set, only list matching rooms.
- #mute_published_track(room:, identity:, track_sid:, muted:) ⇒ Object
- #remove_participant(room:, identity:) ⇒ Object
- #send_data(room:, data:, kind:, destination_sids: []) ⇒ Object
- #update_participant(room:, identity:, metadata: nil, permission: nil) ⇒ Object
- #update_room_metadata(room:, metadata:) ⇒ Object
- #update_subscriptions(room:, identity:, track_sids:, subscribe:) ⇒ Object
Methods included from AuthMixin
Constructor Details
#initialize(base_url, api_key: nil, api_secret: nil) ⇒ RoomServiceClient
Returns a new instance of RoomServiceClient.
10 11 12 13 14 |
# File 'lib/livekit/room_service_client.rb', line 10 def initialize(base_url, api_key: nil, api_secret: nil) super(File.join(base_url, "/twirp")) @api_key = api_key @api_secret = api_secret end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/livekit/room_service_client.rb', line 8 def api_key @api_key end |
#api_secret ⇒ Object
Returns the value of attribute api_secret.
8 9 10 |
# File 'lib/livekit/room_service_client.rb', line 8 def api_secret @api_secret end |
Instance Method Details
#create_room(name, empty_timeout: nil, max_participants: nil) ⇒ Object
creates a new room with name
17 18 19 20 21 22 23 |
# File 'lib/livekit/room_service_client.rb', line 17 def create_room(name, empty_timeout: nil, max_participants: nil) self.rpc( :CreateRoom, Proto::ListRoomsRequest(name: name, empty_timeout: empty_timeout, max_participants: max_participants), headers: auth_header(roomCreate: true), ) end |
#delete_room(room:) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/livekit/room_service_client.rb', line 34 def delete_room(room:) self.rpc( :DeleteRoom, Proto::DeleteRoomRequest.new(room: room), headers: auth_header(roomCreate: true), ) end |
#get_participant(room:, identity:) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/livekit/room_service_client.rb', line 58 def get_participant(room:, identity:) self.rpc( :GetParticipant, Proto::RoomParticipantIdentity.new(room: room, identity: identity), headers: auth_header(roomAdmin: true, room: room), ) end |
#list_participants(room:) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/livekit/room_service_client.rb', line 50 def list_participants(room:) self.rpc( :ListParticipants, Proto::ListParticipantsRequest.new(room: room), headers: auth_header(roomAdmin: true, room: room), ) end |
#list_rooms(names: nil) ⇒ Object
Lists rooms, when names is set, only list matching rooms
26 27 28 29 30 31 32 |
# File 'lib/livekit/room_service_client.rb', line 26 def list_rooms(names: nil) self.rpc( :ListRooms, Proto::ListRoomsRequest.new(names: names), headers: auth_header(roomList: true), ) end |
#mute_published_track(room:, identity:, track_sid:, muted:) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/livekit/room_service_client.rb', line 74 def mute_published_track(room:, identity:, track_sid:, muted:) self.rpc( :MutePublishedTrack, Proto::MuteRoomTrackRequest.new( room: room, identity: identity, track_sid: track_sid, muted: muted, ), headers: auth_header(roomAdmin: true, room: room), ) end |
#remove_participant(room:, identity:) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/livekit/room_service_client.rb', line 66 def remove_participant(room:, identity:) self.rpc( :RemoveParticipant, Proto::RoomParticipantIdentity.new(room: room, identity: identity), headers: auth_header(roomAdmin: true, room: room), ) end |
#send_data(room:, data:, kind:, destination_sids: []) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/livekit/room_service_client.rb', line 115 def send_data(room:, data:, kind:, destination_sids: []) self.rpc( :SendData, Proto::SendDataRequest.new( room: room, data: data, kind: kind, destination_sids: destination_sids, ), headers: auth_header(roomAdmin: true, room: room), ) end |
#update_participant(room:, identity:, metadata: nil, permission: nil) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/livekit/room_service_client.rb', line 87 def update_participant(room:, identity:, metadata: nil, permission: nil) req = Proto::UpdateParticipantRequest.new(room: room, identity: identity) if req. = end if req. = end self.rpc( :UpdateParticipant, req, headers: auth_header(roomAdmin: true, room: room), ) end |
#update_room_metadata(room:, metadata:) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/livekit/room_service_client.rb', line 42 def (room:, metadata:) self.rpc( :UpdateRoomMetadata, Proto::UpdateRoomMetadataRequest.new(room: room, metadata: ), headers: auth_header(roomAdmin: true, room: room), ) end |
#update_subscriptions(room:, identity:, track_sids:, subscribe:) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/livekit/room_service_client.rb', line 102 def update_subscriptions(room:, identity:, track_sids:, subscribe:) self.rpc( :UpdateSubscriptions, Proto::UpdateSubscriptionsRequest.new( room: room, identity: identity, track_sids: track_sids, subscribe: subscribe, ), headers: auth_header(roomAdmin: true, room: room), ) end |