Implement live kit promotion/demotion
This commit is contained in:
parent
8669b08161
commit
4da9d61a42
9 changed files with 223 additions and 42 deletions
|
@ -11,10 +11,18 @@ pub trait Client: Send + Sync {
|
|||
async fn create_room(&self, name: String) -> Result<()>;
|
||||
async fn delete_room(&self, name: String) -> Result<()>;
|
||||
async fn remove_participant(&self, room: String, identity: String) -> Result<()>;
|
||||
async fn update_participant(
|
||||
&self,
|
||||
room: String,
|
||||
identity: String,
|
||||
permission: proto::ParticipantPermission,
|
||||
) -> Result<()>;
|
||||
fn room_token(&self, room: &str, identity: &str) -> Result<String>;
|
||||
fn guest_token(&self, room: &str, identity: &str) -> Result<String>;
|
||||
}
|
||||
|
||||
pub struct LiveKitParticipantUpdate {}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct LiveKitClient {
|
||||
http: reqwest::Client,
|
||||
|
@ -131,6 +139,27 @@ impl Client for LiveKitClient {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
async fn update_participant(
|
||||
&self,
|
||||
room: String,
|
||||
identity: String,
|
||||
permission: proto::ParticipantPermission,
|
||||
) -> Result<()> {
|
||||
let _: proto::ParticipantInfo = self
|
||||
.request(
|
||||
"twirp/livekit.RoomService/UpdateParticipant",
|
||||
token::VideoGrant::to_admin(&room),
|
||||
proto::UpdateParticipantRequest {
|
||||
room: room.clone(),
|
||||
identity,
|
||||
metadata: "".to_string(),
|
||||
permission: Some(permission),
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn room_token(&self, room: &str, identity: &str) -> Result<String> {
|
||||
token::create(
|
||||
&self.key,
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
pub mod api;
|
||||
mod proto;
|
||||
pub mod proto;
|
||||
pub mod token;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue