Initial change propagation work
All checks were successful
CI / Formatting (push) Successful in 42s

This commit is contained in:
Michael Bradley 2025-10-26 00:44:30 -04:00
parent fe967d70b9
commit 3dfeae14f7
Signed by: MichaelBradley
SSH key fingerprint: SHA256:BKO2eI2LPsCbQS3n3i5SdwZTAIV3F1lHezR07qP+Ob0
13 changed files with 146 additions and 72 deletions

View file

@ -18,8 +18,8 @@ impl Default for Config {
}
}
pub fn format_message(id: Uuid, data: &Vec<u8>) -> Vec<u8> {
[id.as_bytes(), data.as_slice()].concat()
pub fn format_message(peer: Uuid, entity: Uuid, data: &Vec<u8>) -> Vec<u8> {
[peer.as_bytes(), entity.as_bytes(), data.as_slice()].concat()
}
pub fn handle_network_input(
@ -33,7 +33,6 @@ pub fn handle_network_input(
for (message, address) in from_socket.iter() {
match Packet::try_from(message) {
Ok(packet) => {
// TODO: Handle packet variant
if !packet.message.is_empty() {
to_app.write(packet.clone().into());
}
@ -63,7 +62,7 @@ pub fn handle_network_output(
for OutboundPacket(packet) in from_app.read() {
let peer_id = peer_map.try_get(&packet.peer)?;
let (peer, mut last) = peers.get_mut(*peer_id)?;
let message = format_message(config.id, &packet.message);
let message = format_message(config.id, packet.entity, &packet.message);
to_socket.send(message, peer.addr.into())?;
last.update(&time);
}