This commit is contained in:
Luuk van Oijen committed 2023-11-20 14:20:12 +01:00
1 parent 223c9a5064
commit 4551a2da60
1 file changed
+11 -46
+11 -46
View File
@@ -269,42 +269,18 @@ impl Server {
}) })
} }
async fn process_tcp(&mut self) -> anyhow::Result<()> { pub fn get_server_status(&self) -> ServerStatus {
// 'packet_wait: loop { ServerStatus {
// // Process all the clients (TCP) player_count: self.clients.len(),
// let mut packets = Vec::new(); player_list: self.clients.iter().map(|client| {
// for i in 0..self.clients.len() { format!("{};", &client.get_name())
// if let Some(client) = self.clients.get_mut(i) { }).collect(),
// match client.process().await { // max_players: self.max_players, // TODO: Support this
// Ok(packet_opt) => { max_players: self.config.general.max_players,
// if let Some(raw_packet) = packet_opt { }
// packets.push((i, raw_packet)); }
// }
// }
// Err(e) => client.kick(&format!("Kicked: {:?}", e)).await,
// }
//
// // More efficient than broadcasting as we are already looping
// for name in joined_names.iter() {
// self.clients[i]
// .queue_packet(Packet::Notification(NotificationPacket::new(format!(
// "Welcome {}!",
// name.to_string()
// ))))
// .await;
// }
// }
// }
//
// if packets.len() > 0 {
// for (i, raw_packet) in packets {
// self.parse_packet(i, raw_packet).await?;
// }
//
// break 'packet_wait;
// }
// }
async fn process_tcp(&mut self) -> anyhow::Result<()> {
if self.clients.len() > 0 { if self.clients.len() > 0 {
let (result, index, _) = futures::future::select_all( let (result, index, _) = futures::future::select_all(
self.clients.iter_mut().map(|client| Box::pin(client.process_blocking())) self.clients.iter_mut().map(|client| Box::pin(client.process_blocking()))
@@ -330,17 +306,6 @@ impl Server {
Ok(()) Ok(())
} }
pub fn get_server_status(&self) -> ServerStatus {
ServerStatus {
player_count: self.clients.len(),
player_list: self.clients.iter().map(|client| {
format!("{};", &client.get_name())
}).collect(),
// max_players: self.max_players, // TODO: Support this
max_players: self.config.general.max_players,
}
}
async fn process_udp(&mut self) -> anyhow::Result<()> { async fn process_udp(&mut self) -> anyhow::Result<()> {
// Process UDP packets // Process UDP packets
// TODO: Use a UDP addr -> client ID look up table // TODO: Use a UDP addr -> client ID look up table