|
|
|
@ -115,7 +115,8 @@ Let's add waiting to the server:
|
|
|
|
|
# Event::Message { from, to, msg } => {
|
|
|
|
|
# for addr in to {
|
|
|
|
|
# if let Some(peer) = peers.get_mut(&addr) {
|
|
|
|
|
# peer.send(format!("from {}: {}\n", from, msg)).await?
|
|
|
|
|
# let msg = format!("from {}: {}\n", from, msg);
|
|
|
|
|
# peer.send(msg).await?
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
@ -217,7 +218,8 @@ async fn broker(mut events: Receiver<Event>) -> Result<()> {
|
|
|
|
|
Event::Message { from, to, msg } => {
|
|
|
|
|
for addr in to {
|
|
|
|
|
if let Some(peer) = peers.get_mut(&addr) {
|
|
|
|
|
peer.send(format!("from {}: {}\n", from, msg)).await?
|
|
|
|
|
let msg = format!("from {}: {}\n", from, msg);
|
|
|
|
|
peer.send(msg).await?
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|