Implemented exp. backoff and timeout for room joins. Fixes #7
This commit is contained in:
parent
ad3245f884
commit
88f7d9740c
1 changed files with 5 additions and 2 deletions
|
@ -128,7 +128,8 @@ pub async fn send(from_mail: &Option<Mailbox>, recipient: &Mailbox, plain_conten
|
||||||
// Continuously check whether the room has been joined.
|
// Continuously check whether the room has been joined.
|
||||||
// Joins can be significantly delayed, depending on the room and the server
|
// Joins can be significantly delayed, depending on the room and the server
|
||||||
let mut joined = false;
|
let mut joined = false;
|
||||||
while !joined {
|
let mut counter = 0;
|
||||||
|
while !joined && counter < 10{
|
||||||
match c.get_room(&roomid) {
|
match c.get_room(&roomid) {
|
||||||
Some(Room::Joined(_)) => joined = true,
|
Some(Room::Joined(_)) => joined = true,
|
||||||
_ => (),
|
_ => (),
|
||||||
|
@ -137,12 +138,14 @@ pub async fn send(from_mail: &Option<Mailbox>, recipient: &Mailbox, plain_conten
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(_e) => (),
|
Err(_e) => (),
|
||||||
};
|
};
|
||||||
std::thread::sleep(std::time::Duration::from_millis(250));
|
std::thread::sleep(std::time::Duration::from_millis(u64::pow(2, counter) * 100));
|
||||||
|
counter += 1;
|
||||||
}
|
}
|
||||||
if let Some(Room::Joined(joined)) = c.get_room(&roomid) {
|
if let Some(Room::Joined(joined)) = c.get_room(&roomid) {
|
||||||
joined
|
joined
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
println!("Joining room timed out.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue