Skip to content

Commit

Permalink
Possibly fix (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahasselbring committed Jun 13, 2023
1 parent 1786a91 commit 2a36511
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions game_controller_net/src/control_message_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ impl ControlMessageSender {
})
}

/// This function runs the sender until an error occurs.
pub async fn run(&self) -> Result<()> {
/// This function runs the sender indefinitely.
pub async fn run(&self) {
let mut interval = interval(Self::SEND_INTERVAL);
let mut packet_number: u8 = 0;
loop {
Expand All @@ -70,7 +70,7 @@ impl ControlMessageSender {
self.to_monitor,
)
.into();
self.socket.send(&buffer).await?;
let _ = self.socket.send(&buffer).await;
packet_number = packet_number.wrapping_add(1);
}
}
Expand Down
5 changes: 3 additions & 2 deletions game_controller_net/src/status_message_forwarder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ impl StatusMessageForwarder {
})
}

/// This function runs the forwarder until an error occurs.
/// This function runs the forwarder until an error occurs. Network errors during sending are
/// ignored because the network might change and we shouldn't crash in that case.
pub async fn run(&mut self) -> Result<()> {
loop {
let (source, buffer) = self.message_receiver.recv().await?;
Expand All @@ -54,7 +55,7 @@ impl StatusMessageForwarder {
}
_ => todo!("implement forwarding of IPv6 status messages"),
};
self.socket.send(&prefixed_buffer).await?;
let _ = self.socket.send(&prefixed_buffer).await;
}
}
}
5 changes: 3 additions & 2 deletions game_controller_runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async fn start_network(
.await
.context("could not create control message sender")?;

join_set.spawn(async move { control_message_sender.run().await.unwrap() });
join_set.spawn(async move { control_message_sender.run().await });

for team in teams {
let team_message_receiver =
Expand Down Expand Up @@ -231,7 +231,8 @@ async fn event_loop(
.await
.unwrap()
.run()
.await
.await;
Ok(())
});
}
{
Expand Down

0 comments on commit 2a36511

Please sign in to comment.