Fix hearbeat

This commit is contained in:
Bastian Gruber 2023-05-21 14:43:52 +02:00
parent 4a5f98858b
commit 3776d7bb4c
No known key found for this signature in database
GPG key ID: BE9F8C772B188CBF

View file

@ -179,6 +179,7 @@ impl Handler {
frame: ClientFrames,
send_message: mpsc::Sender<ServerFrames>,
) -> crate::Result<()> {
debug!(?frame);
match frame {
ClientFrames::Plate { plate, timestamp } => {
info!("Receive new plate {plate} {timestamp}");
@ -201,10 +202,12 @@ impl Handler {
.await;
}
ClientFrames::WantHeartbeat { interval } => {
tokio::spawn(async move {
let mut heartbeat = Heartbeat::new(interval, send_message.clone());
heartbeat.start().await;
});
if interval > 0 {
tokio::spawn(async move {
let mut heartbeat = Heartbeat::new(interval, send_message.clone());
heartbeat.start().await;
});
}
}
ClientFrames::IAmCamera { road, mile, limit } => {
if self.connection_type.is_some() {