feat: gracefully handle servers, which could not be found with the addr
This commit is contained in:
parent
5bfff0a081
commit
0d5fec173d
3 changed files with 56 additions and 27 deletions
|
|
@ -3,6 +3,7 @@ use std::fmt;
|
|||
use tokio::{io::AsyncWriteExt, net::TcpStream};
|
||||
|
||||
use crate::{
|
||||
mc_server,
|
||||
packets::{
|
||||
clientbound::status::{StatusStructNew, StatusTrait},
|
||||
serverbound::handshake::Handshake,
|
||||
|
|
@ -26,6 +27,22 @@ pub async fn handle_ping(client_stream: &mut TcpStream) -> Result<(), OpaqueErro
|
|||
))),
|
||||
}
|
||||
}
|
||||
/// small helper function for sending `status request` to client
|
||||
pub async fn complete_status_request(
|
||||
client_stream: &mut TcpStream,
|
||||
status_struct: StatusStructNew,
|
||||
) -> Result<(), OpaqueError> {
|
||||
let status_res =
|
||||
crate::packets::clientbound::status::StatusResponse::set_json(Box::new(status_struct))
|
||||
.await;
|
||||
status_res
|
||||
.send_packet(client_stream)
|
||||
.await
|
||||
.map_err(|_| "Failed to send status packet")?;
|
||||
|
||||
mc_server::handle_ping(client_stream).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Disconnects the client.
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue