This commit is contained in:
parent
fe967d70b9
commit
3dfeae14f7
13 changed files with 146 additions and 72 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue