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 crate::{proto, token};
|
||||||
use hyper::{client::HttpConnector, Request, Uri};
|
use anyhow::{anyhow, Result};
|
||||||
|
use hyper::{client::HttpConnector, header::AUTHORIZATION, Method, Request, Uri};
|
||||||
|
use std::future::Future;
|
||||||
|
|
||||||
pub struct Client {
|
pub struct Client {
|
||||||
http: hyper::Client<HttpConnector>,
|
http: hyper::Client<HttpConnector>,
|
||||||
|
@ -14,23 +16,46 @@ impl Client {
|
||||||
assert!(uri.authority().is_some(), "base uri must have an authority");
|
assert!(uri.authority().is_some(), "base uri must have an authority");
|
||||||
Self {
|
Self {
|
||||||
http: hyper::Client::new(),
|
http: hyper::Client::new(),
|
||||||
uri: uri,
|
uri,
|
||||||
key,
|
key,
|
||||||
secret,
|
secret,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_room(&self) {
|
pub fn create_room(&self, name: String) -> impl Future<Output = Result<proto::Room>> {
|
||||||
// let mut uri = url.clone();
|
let token = token::create(
|
||||||
// uri.set_path_and_query()
|
&self.key,
|
||||||
|
&self.secret,
|
||||||
|
None,
|
||||||
|
token::VideoGrant {
|
||||||
|
room_create: Some(true),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
let client = self.http.clone();
|
||||||
let uri = Uri::builder()
|
let uri = Uri::builder()
|
||||||
.scheme(self.uri.scheme().unwrap().clone())
|
.scheme(self.uri.scheme().unwrap().clone())
|
||||||
.authority(self.uri.authority().unwrap().clone())
|
.authority(self.uri.authority().unwrap().clone())
|
||||||
.path_and_query("twirp/livekit.RoomService/CreateRoom")
|
.path_and_query("twirp/livekit.RoomService/CreateRoom")
|
||||||
.build();
|
.build();
|
||||||
|
async move {
|
||||||
// token::create(api_key, secret_key, room_name, participant_name)
|
let token = token?;
|
||||||
// self.http.request(req)
|
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