| 1 | use std::sync::Arc; |
| 2 | |
| 3 | use quinn::Connection; |
| 4 | use tracing::warn; |
| 5 | |
| 6 | use crate::{hub::Client, network::Shared, publish}; |
| 7 | |
| 8 | pub(crate) async fn relay_datagrams(connection: Connection, client: Arc<Client>, shared: Shared) { |
| 9 | while let Ok(bytes) = connection.read_datagram().await { |
| 10 | let broadcasts = shared.services.rooms.relay(&client, &bytes); |
| 11 | if broadcasts.is_empty() { |
| 12 | continue; |
| 13 | } |
| 14 | if let Err(error) = publish::job(&shared, async |_| Ok(broadcasts)).await { |
| 15 | warn!("relay: {error}"); |
| 16 | } |
| 17 | } |
| 18 | } |