WIP
This commit is contained in:
parent
19a2752674
commit
f09d6b7b95
1 changed files with 34 additions and 9 deletions
|
@ -1,5 +1,7 @@
|
|||
use crate::token;
|
||||
use hyper::{client::HttpConnector, Request, Uri};
|
||||
use crate::{proto, token};
|
||||
use anyhow::{anyhow, Result};
|
||||
use hyper::{client::HttpConnector, header::AUTHORIZATION, Method, Request, Uri};
|
||||
use std::future::Future;
|
||||
|
||||
pub struct Client {
|
||||
http: hyper::Client<HttpConnector>,
|
||||
|
@ -14,23 +16,46 @@ impl Client {
|
|||
assert!(uri.authority().is_some(), "base uri must have an authority");
|
||||
Self {
|
||||
http: hyper::Client::new(),
|
||||
uri: uri,
|
||||
uri,
|
||||
key,
|
||||
secret,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_room(&self) {
|
||||
// let mut uri = url.clone();
|
||||
// uri.set_path_and_query()
|
||||
pub fn create_room(&self, name: String) -> impl Future<Output = Result<proto::Room>> {
|
||||
let token = token::create(
|
||||
&self.key,
|
||||
&self.secret,
|
||||
None,
|
||||
token::VideoGrant {
|
||||
room_create: Some(true),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
|
||||
let client = self.http.clone();
|
||||
let uri = Uri::builder()
|
||||
.scheme(self.uri.scheme().unwrap().clone())
|
||||
.authority(self.uri.authority().unwrap().clone())
|
||||
.path_and_query("twirp/livekit.RoomService/CreateRoom")
|
||||
.build();
|
||||
|
||||
// token::create(api_key, secret_key, room_name, participant_name)
|
||||
// self.http.request(req)
|
||||
async move {
|
||||
let token = token?;
|
||||
let uri = uri?;
|
||||
let body = proto::CreateRoomRequest {
|
||||
name: todo!(),
|
||||
empty_timeout: todo!(),
|
||||
max_participants: todo!(),
|
||||
node_id: todo!(),
|
||||
metadata: todo!(),
|
||||
egress: todo!(),
|
||||
};
|
||||
let mut request = Request::builder()
|
||||
.uri(uri)
|
||||
.method(Method::POST)
|
||||
.header(AUTHORIZATION, format!("Bearer {}", token))
|
||||
.body(body);
|
||||
Err(anyhow!("yeah"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue