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, egress: nil, metadata: nil, min_playout_delay: nil, max_playout_delay: nil, sync_streams: nil, departure_timeout: nil) ⇒ Object
- #delete_room(room:) ⇒ Object
- #forward_participant(room:, identity:, destination_room:) ⇒ Object
- #get_participant(room:, identity:) ⇒ Object
-
#initialize(base_url, api_key: nil, api_secret: nil, token: nil, failover: true, connection: nil) ⇒ RoomServiceClient
constructor
A new instance of RoomServiceClient.
- #list_participants(room:) ⇒ Object
- #list_rooms(names: nil) ⇒ Object
- #move_participant(room:, identity:, destination_room:) ⇒ Object
- #mute_published_track(room:, identity:, track_sid:, muted:) ⇒ Object
- #remove_participant(room:, identity:) ⇒ Object
- #send_data(room:, data:, kind:, destination_sids: [], destination_identities: []) ⇒ Object
- #update_participant(room:, identity:, metadata: nil, permission: nil, name: nil, attributes: 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, token: nil, failover: true, connection: nil) ⇒ RoomServiceClient
Returns a new instance of RoomServiceClient.
16 17 18 19 20 21 |
# File 'lib/livekit/room_service_client.rb', line 16 def initialize(base_url, api_key: nil, api_secret: nil, token: nil, failover: true, connection: nil) super(connection || LiveKit::Failover.connection(base_url, failover)) @api_key = api_key @api_secret = api_secret @token = token end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
14 15 16 |
# File 'lib/livekit/room_service_client.rb', line 14 def api_key @api_key end |
#api_secret ⇒ Object
Returns the value of attribute api_secret.
14 15 16 |
# File 'lib/livekit/room_service_client.rb', line 14 def api_secret @api_secret end |
Instance Method Details
#create_room(name, empty_timeout: nil, max_participants: nil, egress: nil, metadata: nil, min_playout_delay: nil, max_playout_delay: nil, sync_streams: nil, departure_timeout: nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/livekit/room_service_client.rb', line 23 def create_room(name, empty_timeout: nil, max_participants: nil, egress: nil, metadata: nil, min_playout_delay: nil, max_playout_delay: nil, sync_streams: nil, departure_timeout: nil ) rpc!( :CreateRoom, Proto::CreateRoomRequest.new( name: name, empty_timeout: empty_timeout, departure_timeout: departure_timeout, max_participants: max_participants, egress: egress, metadata: , min_playout_delay: min_playout_delay, max_playout_delay: max_playout_delay, sync_streams: sync_streams ), headers:auth_header(video_grant: VideoGrant.new(roomCreate: true)), ) end |
#delete_room(room:) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/livekit/room_service_client.rb', line 58 def delete_room(room:) rpc!( :DeleteRoom, Proto::DeleteRoomRequest.new(room: room), headers:auth_header(video_grant: VideoGrant.new(roomCreate: true)), ) end |
#forward_participant(room:, identity:, destination_room:) ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/livekit/room_service_client.rb', line 98 def forward_participant(room:, identity:, destination_room:) rpc!( :ForwardParticipant, Proto::ForwardParticipantRequest.new(room: room, identity: identity, destination_room: destination_room), headers:auth_header(video_grant: VideoGrant.new(roomAdmin: true, room: room, destinationRoom: destination_room)), ) end |
#get_participant(room:, identity:) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/livekit/room_service_client.rb', line 82 def get_participant(room:, identity:) rpc!( :GetParticipant, Proto::RoomParticipantIdentity.new(room: room, identity: identity), headers:auth_header(video_grant: VideoGrant.new(roomAdmin: true, room: room)), ) end |
#list_participants(room:) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/livekit/room_service_client.rb', line 74 def list_participants(room:) rpc!( :ListParticipants, Proto::ListParticipantsRequest.new(room: room), headers:auth_header(video_grant: VideoGrant.new(roomAdmin: true, room: room)), ) end |
#list_rooms(names: nil) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/livekit/room_service_client.rb', line 50 def list_rooms(names: nil) rpc!( :ListRooms, Proto::ListRoomsRequest.new(names: names), headers:auth_header(video_grant: VideoGrant.new(roomList: true)), ) end |
#move_participant(room:, identity:, destination_room:) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/livekit/room_service_client.rb', line 106 def move_participant(room:, identity:, destination_room:) rpc!( :MoveParticipant, Proto::MoveParticipantRequest.new(room: room, identity: identity, destination_room: destination_room), headers:auth_header(video_grant: VideoGrant.new(roomAdmin: true, room: room, destinationRoom: destination_room)), ) end |
#mute_published_track(room:, identity:, track_sid:, muted:) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/livekit/room_service_client.rb', line 114 def mute_published_track(room:, identity:, track_sid:, muted:) rpc!( :MutePublishedTrack, Proto::MuteRoomTrackRequest.new( room: room, identity: identity, track_sid: track_sid, muted: muted, ), headers:auth_header(video_grant: VideoGrant.new(roomAdmin: true, room: room)), ) end |
#remove_participant(room:, identity:) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/livekit/room_service_client.rb', line 90 def remove_participant(room:, identity:) rpc!( :RemoveParticipant, Proto::RoomParticipantIdentity.new(room: room, identity: identity), headers:auth_header(video_grant: VideoGrant.new(roomAdmin: true, room: room)), ) end |
#send_data(room:, data:, kind:, destination_sids: [], destination_identities: []) ⇒ Object
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/livekit/room_service_client.rb', line 172 def send_data(room:, data:, kind:, destination_sids: [], destination_identities: [] ) rpc!( :SendData, Proto::SendDataRequest.new( room: room, data: data, kind: kind, destination_sids: destination_sids, destination_identities: destination_identities, nonce: SecureRandom.random_bytes(16) ), headers:auth_header(video_grant: VideoGrant.new(roomAdmin: true, room: room)), ) end |
#update_participant(room:, identity:, metadata: nil, permission: nil, name: nil, attributes: nil) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/livekit/room_service_client.rb', line 127 def update_participant( room:, identity:, metadata: nil, permission: nil, name: nil, attributes: nil ) req = Proto::UpdateParticipantRequest.new(room: room, identity: identity) if req. = end if req. = end if name req.name = name end if attributes attr_map = Google::Protobuf::Map.new(:string, :string) attributes.each do |k, v| attr_map[k.to_s] = v.to_s end req.attributes = attr_map end rpc!( :UpdateParticipant, req, headers:auth_header(video_grant: VideoGrant.new(roomAdmin: true, room: room)), ) end |
#update_room_metadata(room:, metadata:) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/livekit/room_service_client.rb', line 66 def (room:, metadata:) rpc!( :UpdateRoomMetadata, Proto::UpdateRoomMetadataRequest.new(room: room, metadata: ), headers:auth_header(video_grant: VideoGrant.new(roomAdmin: true, room: room)), ) end |
#update_subscriptions(room:, identity:, track_sids:, subscribe:) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/livekit/room_service_client.rb', line 159 def update_subscriptions(room:, identity:, track_sids:, subscribe:) rpc!( :UpdateSubscriptions, Proto::UpdateSubscriptionsRequest.new( room: room, identity: identity, track_sids: track_sids, subscribe: subscribe, ), headers:auth_header(video_grant: VideoGrant.new(roomAdmin: true, room: room)), ) end |