Don't expose heartbeat to app

This commit is contained in:
Michael Bradley 2025-07-05 19:28:14 -04:00
parent e58629c2f1
commit 58795eb87e
Signed by: MichaelBradley
SSH key fingerprint: SHA256:o/aaeYtRubILK7OYYjYP12DmU7BsPUhKji1AgaQ+ge4
4 changed files with 7 additions and 6 deletions

View file

@ -11,7 +11,6 @@ pub fn handle_new_peer(
) {
if let Some(seed) = seed {
for peer in new_peers {
warn!("Sending seed to peer: {}", peer.uuid);
outbound.write(OutboundPacket(Packet::new((*seed).into(), peer.uuid)));
}
}

View file

@ -26,7 +26,9 @@ pub fn handle_network_input(
.into());
}
let uuid = Uuid::from_slice(message.split_off(message.len() - 16).as_slice())?;
to_app.write(InboundPacket(Packet::new(message, uuid)));
if !message.is_empty() {
to_app.write(InboundPacket(Packet::new(message, uuid)));
}
if let Some(peer_id) = peer_map.get(&uuid) {
let (peer, mut last) = peers.get_mut(*peer_id)?;
last.update(&time);
@ -74,7 +76,7 @@ pub fn heartbeat(
}
}
pub fn timeouts(
pub fn timeout(
peers: Query<(&Peer, &PeerReceiveTiming)>,
time: Res<Time>,
mut delete: EventWriter<PeerChangeEvent>,

View file

@ -107,7 +107,7 @@ pub fn handle_peer_change(
peer_map.remove(&change.peer);
}
} else if let Some(addr) = change.addr {
info!("Adding peer {} ({:?})", change.peer, change.addr);
info!("Adding peer {} ({})", change.peer, addr);
peer_map.insert(
change.peer,
commands

View file

@ -4,7 +4,7 @@ use bevy::prelude::*;
use uuid::Uuid;
use super::{
io::{Config, handle_network_input, handle_network_output, heartbeat, timeouts},
io::{Config, handle_network_input, handle_network_output, heartbeat, timeout},
packet::{InboundPacket, OutboundPacket},
peer::{Peer, PeerChangeEvent, PeerMap, handle_new_peer, handle_peer_change},
queues::{NetworkReceive, NetworkSend},
@ -40,7 +40,7 @@ impl Plugin for NetIOPlugin {
)
.add_systems(
FixedUpdate,
(heartbeat, timeouts, handle_new_peer).run_if(in_state(NetworkState::MultiPlayer)),
(heartbeat, timeout, handle_new_peer).run_if(in_state(NetworkState::MultiPlayer)),
)
.add_systems(
FixedPostUpdate,