Update euphoxide
This commit is contained in:
parent
2201e04e15
commit
28899965c7
3 changed files with 9 additions and 5 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -290,7 +290,7 @@ checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "euphoxide"
|
name = "euphoxide"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ features = ["rustls-tls-native-roots"]
|
||||||
|
|
||||||
[dependencies.euphoxide]
|
[dependencies.euphoxide]
|
||||||
git = "https://github.com/Garmelon/euphoxide.git"
|
git = "https://github.com/Garmelon/euphoxide.git"
|
||||||
rev = "2579a9860da7b0eaa9aded098921c64f8ea2abab"
|
rev = "5ac16db3fcf9a5a6705630e92f3ad859e99cd891"
|
||||||
|
|
||||||
# [patch."https://github.com/Garmelon/euphoxide.git"]
|
# [patch."https://github.com/Garmelon/euphoxide.git"]
|
||||||
# toss = { path = "../euphoxide/" }
|
# toss = { path = "../euphoxide/" }
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,10 @@ use tokio_tungstenite::tungstenite::http::{header, HeaderValue};
|
||||||
use crate::macros::ok_or_return;
|
use crate::macros::ok_or_return;
|
||||||
use crate::vault::{EuphVault, Vault};
|
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)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error("room stopped")]
|
#[error("room stopped")]
|
||||||
|
|
@ -106,7 +110,7 @@ impl State {
|
||||||
info!("e&{}: could not connect", name);
|
info!("e&{}: could not connect", name);
|
||||||
event_tx.send(Event::Disconnected)?;
|
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 {
|
match tokio_tungstenite::connect_async(request).await {
|
||||||
Ok((ws, response)) => {
|
Ok((ws, response)) => {
|
||||||
Self::update_cookies(vault.vault(), &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() => {
|
Err(tungstenite::Error::Http(resp)) if resp.status().is_client_error() => {
|
||||||
bail!("room {name} doesn't exist");
|
bail!("room {name} doesn't exist");
|
||||||
|
|
@ -157,7 +161,7 @@ impl State {
|
||||||
|
|
||||||
async fn regularly_request_logs(event_tx: &mpsc::UnboundedSender<Event>) {
|
async fn regularly_request_logs(event_tx: &mpsc::UnboundedSender<Event>) {
|
||||||
loop {
|
loop {
|
||||||
tokio::time::sleep(Duration::from_secs(10)).await; // TODO Make configurable
|
tokio::time::sleep(LOG_INTERVAL).await;
|
||||||
let _ = event_tx.send(Event::RequestLogs);
|
let _ = event_tx.send(Event::RequestLogs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue