diff --git a/Cargo.lock b/Cargo.lock index 13fc180..c6ada51 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -290,7 +290,7 @@ checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" [[package]] name = "euphoxide" version = "0.1.0" -source = "git+https://github.com/Garmelon/euphoxide.git?rev=2579a9860da7b0eaa9aded098921c64f8ea2abab#2579a9860da7b0eaa9aded098921c64f8ea2abab" +source = "git+https://github.com/Garmelon/euphoxide.git?rev=5ac16db3fcf9a5a6705630e92f3ad859e99cd891#5ac16db3fcf9a5a6705630e92f3ad859e99cd891" dependencies = [ "futures", "serde", diff --git a/Cargo.toml b/Cargo.toml index 1336a60..8d269ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ features = ["rustls-tls-native-roots"] [dependencies.euphoxide] git = "https://github.com/Garmelon/euphoxide.git" -rev = "2579a9860da7b0eaa9aded098921c64f8ea2abab" +rev = "5ac16db3fcf9a5a6705630e92f3ad859e99cd891" # [patch."https://github.com/Garmelon/euphoxide.git"] # toss = { path = "../euphoxide/" } diff --git a/src/euph/room.rs b/src/euph/room.rs index 7ceaada..e226e8c 100644 --- a/src/euph/room.rs +++ b/src/euph/room.rs @@ -20,6 +20,10 @@ use tokio_tungstenite::tungstenite::http::{header, HeaderValue}; use crate::macros::ok_or_return; use crate::vault::{EuphVault, Vault}; +const TIMEOUT: Duration = Duration::from_secs(30); +const RECONNECT_INTERVAL: Duration = Duration::from_secs(5); +const LOG_INTERVAL: Duration = Duration::from_secs(10); + #[derive(Debug, thiserror::Error)] pub enum Error { #[error("room stopped")] @@ -106,7 +110,7 @@ impl State { info!("e&{}: could not connect", name); event_tx.send(Event::Disconnected)?; } - tokio::time::sleep(Duration::from_secs(5)).await; // TODO Make configurable + tokio::time::sleep(RECONNECT_INTERVAL).await; } } @@ -143,7 +147,7 @@ impl State { match tokio_tungstenite::connect_async(request).await { Ok((ws, response)) => { Self::update_cookies(vault.vault(), &response); - Ok(Some(euphoxide::wrap(ws))) + Ok(Some(euphoxide::wrap(ws, TIMEOUT))) } Err(tungstenite::Error::Http(resp)) if resp.status().is_client_error() => { bail!("room {name} doesn't exist"); @@ -157,7 +161,7 @@ impl State { async fn regularly_request_logs(event_tx: &mpsc::UnboundedSender) { loop { - tokio::time::sleep(Duration::from_secs(10)).await; // TODO Make configurable + tokio::time::sleep(LOG_INTERVAL).await; let _ = event_tx.send(Event::RequestLogs); } }