awaiting the channel send
This commit is contained in:
parent
0cbe0c767e
commit
1df7952986
2 changed files with 9 additions and 4 deletions
|
|
@ -1,7 +1,9 @@
|
||||||
use crate::frame::ServerFrames;
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tracing::debug;
|
use tracing::{debug, error};
|
||||||
|
|
||||||
|
use crate::frame::ServerFrames;
|
||||||
|
|
||||||
pub(crate) struct Heartbeat {
|
pub(crate) struct Heartbeat {
|
||||||
is_running: bool,
|
is_running: bool,
|
||||||
|
|
@ -35,7 +37,10 @@ impl Heartbeat {
|
||||||
loop {
|
loop {
|
||||||
debug!("Heartbeat");
|
debug!("Heartbeat");
|
||||||
interval.tick().await;
|
interval.tick().await;
|
||||||
let _ = self.message.send(ServerFrames::Heartbeat);
|
if let Err(e) = self.message.send(ServerFrames::Heartbeat).await {
|
||||||
|
error!("Error sending heartbeat: {}", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ impl Handler {
|
||||||
|
|
||||||
}
|
}
|
||||||
message = receive_message.recv() => {
|
message = receive_message.recv() => {
|
||||||
debug!(?message);
|
info!("Received a message through the channel");
|
||||||
match message {
|
match message {
|
||||||
Some(message) => {
|
Some(message) => {
|
||||||
let _ = self.connection.write_frame(message).await;
|
let _ = self.connection.write_frame(message).await;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue