remove duplicate log messages when ignoring events

This commit is contained in:
Ferdinand Schober
2023-12-15 08:17:49 +01:00
parent 010db79918
commit 0c275bc2de

View File

@@ -50,6 +50,7 @@ pub struct Server {
socket: UdpSocket, socket: UdpSocket,
frontend_rx: Receiver<FrontendEvent>, frontend_rx: Receiver<FrontendEvent>,
frontend_tx: Sender<FrontendEvent>, frontend_tx: Sender<FrontendEvent>,
last_ignored: Option<SocketAddr>,
} }
impl Server { impl Server {
@@ -79,6 +80,7 @@ impl Server {
state: State::Receiving, state: State::Receiving,
frontend_rx, frontend_rx,
frontend_tx, frontend_tx,
last_ignored: None,
}; };
// add clients from config // add clients from config
@@ -286,11 +288,19 @@ impl Server {
let handle = match self.client_manager.get_client(addr) { let handle = match self.client_manager.get_client(addr) {
Some(a) => a, Some(a) => a,
None => { None => {
log::warn!("ignoring event from client {addr:?}"); if self.last_ignored.is_none()
|| self.last_ignored.is_some() && self.last_ignored.unwrap() != addr
{
log::warn!("ignoring events from client {addr}");
self.last_ignored = Some(addr);
}
return; return;
} }
}; };
// next event can be logged as ignored again
self.last_ignored = None;
log::trace!("{:20} <-<-<-<------ {addr} ({handle})", event.to_string()); log::trace!("{:20} <-<-<-<------ {addr} ({handle})", event.to_string());
let state = match self.client_manager.get_mut(handle) { let state = match self.client_manager.get_mut(handle) {
Some(s) => s, Some(s) => s,