Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Calling support #327

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/push_service/calling.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use super::{HttpAuthOverride, PushService, ReqwestExt, ServiceError};
use crate::configuration::Endpoint;
use reqwest::Method;
use serde::Deserialize;

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TurnServerInfo {
pub username: String,
pub password: String,
pub hostname: Option<String>,
pub urls: Vec<String>,
#[serde(default)]
pub urls_with_ips: Vec<String>,
}

impl PushService {
pub async fn get_turn_server_info(
&mut self,
) -> Result<Vec<TurnServerInfo>, ServiceError> {
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
struct GetRelaysResponse {
relays: Vec<TurnServerInfo>,
}

Ok(self
.request(
Method::GET,
Endpoint::service("/v2/calling/relays"),
HttpAuthOverride::NoOverride,
)?
.send()
.await?
.service_error_for_status()
.await?
.json::<GetRelaysResponse>()
.await?
.relays)
}
}
2 changes: 2 additions & 0 deletions src/push_service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub const KEEPALIVE_TIMEOUT_SECONDS: Duration = Duration::from_secs(55);
pub const DEFAULT_DEVICE_ID: u32 = 1;

mod account;
mod calling;
mod cdn;
mod error;
mod keys;
Expand All @@ -34,6 +35,7 @@ mod response;
mod stickers;

pub use account::*;
pub use calling::*;
pub use cdn::*;
pub use error::*;
pub use keys::*;
Expand Down
Loading