awaiting the channel send

This commit is contained in:
Bastian Gruber 2023-05-21 14:48:42 +02:00
parent 0cbe0c767e
commit 1df7952986
No known key found for this signature in database
GPG key ID: BE9F8C772B188CBF
2 changed files with 9 additions and 4 deletions

View file

@ -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;
}
} }
} }
} }

View file

@ -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;