[Fix] Syncronized Webserver & Host behaviour, Fixed the 10 sec default wait on auth

This commit is contained in:
Alex 2026-07-28 18:49:40 +02:00
commit cab2cd7a52
Signed by: alex
SSH key fingerprint: SHA256:D1+Ub8o0v4K5y1JNivW8IxEOelqLSvPmUzBbDIoZkRQ
22 changed files with 2912 additions and 1011 deletions

View file

@ -1,3 +1,5 @@
use std::time::{Duration, Instant};
use mtp::client::MTPConnection;
use mtp::codec::{CommunicationType, CommunicationValue, DataType, DataValue};
use mtp::crypto::{Ed25519Signer, EncryptionType, Keyring, PublicKeyBundle, SigAlgorithm};
@ -89,17 +91,22 @@ pub async fn send_and_receive(
conn: &MTPConnection,
keyring: &Keyring,
server_bundle: &PublicKeyBundle,
) -> Result<(), Box<dyn std::error::Error>> {
) -> Result<Duration, Box<dyn std::error::Error>> {
let msg = build_demo_message(conn.client_id, keyring, server_bundle)?;
println!("Sending: {msg}");
let start = Instant::now();
conn.sender.send(&msg).await?;
match conn.receive().await {
Ok(resp) => {
let roundtrip = start.elapsed();
println!("Received: {resp}");
println!("Message round-trip: {:.3}ms", roundtrip.as_secs_f64() * 1000.0);
Ok(roundtrip)
}
Err(e) => {
eprintln!("Receive error: {e}");
Err(e.into())
}
Err(e) => eprintln!("Receive error: {e}"),
}
Ok(())
}