-
I use it in a server which has to send a message to clients every minute else if &msg == "vosmsg"{
let mut i: i8 = 0;
let delay = time::Duration::from_secs(3);
while i < 5{
loop {
i += 1;
thread::sleep(delay);
getdb::donnees6()
.into_actor(self)
.map(|res, act, ctx| {
let bro: String = res.unwrap_or_else(|e| format!("{}", e));
ctx.text(bro);
// System::current().stop();
}).spawn(ctx);
}
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
robjtede
Jun 2, 2021
Replies: 2 comments 1 reply
-
try using https://docs.rs/actix/0.11.1/actix/prelude/trait.AsyncContext.html#method.run_interval |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
robjtede
This comment was marked as off-topic.
This comment was marked as off-topic.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
try using https://docs.rs/actix/0.11.1/actix/prelude/trait.AsyncContext.html#method.run_interval