- add: handle server select request - add: handle character list request stub - add: start health check function for consul
33 lines
1.3 KiB
Rust
33 lines
1.3 KiB
Rust
use crate::auth_client::AuthClient;
|
|
use crate::handlers::*;
|
|
use crate::packet::Packet;
|
|
use crate::packet_type::PacketType;
|
|
use std::error::Error;
|
|
use std::sync::Arc;
|
|
use tokio::net::TcpStream;
|
|
use tokio::sync::Mutex;
|
|
use tracing::{debug, warn};
|
|
|
|
pub async fn route_packet(stream: &mut TcpStream, packet: Packet, auth_client: Arc<Mutex<AuthClient>>) -> Result<(), Box<dyn Error + Send + Sync>> {
|
|
debug!("Routing packet: {:?}", packet);
|
|
match packet.packet_type {
|
|
PacketType::PakcsAlive => Ok(()),
|
|
PacketType::PakcsAcceptReq => auth::handle_accept_req(stream, packet).await,
|
|
PacketType::PakcsJoinServerReq => auth::handle_join_server_req(stream, packet).await,
|
|
// Login Stuff
|
|
PacketType::PakcsLoginReq => auth::handle_login_req(stream, packet, auth_client).await,
|
|
PacketType::PakcsSrvSelectReq => auth::handle_server_select_req(stream, packet).await,
|
|
PacketType::PakcsChannelListReq => auth::handle_channel_list_req(stream, packet).await,
|
|
|
|
// Character Stuff
|
|
PacketType::PakcsCharListReq => character::handle_char_list_req(stream, packet).await,
|
|
|
|
// 1 => chat::handle_chat(packet).await?,
|
|
// 2 => movement::handle_movement(packet).await?,
|
|
_ => {
|
|
warn!("Unhandled packet type: {:?}", packet.packet_type);
|
|
Ok(())
|
|
},
|
|
}
|
|
}
|