Updated chat handler to use the MessageType enum values instead of numbers

Added local_id tracking for the packet service
Added mob spawning packet in response to game logic events (only for a NearbyUpdate event right now)
This commit is contained in:
2025-07-22 00:23:56 -04:00
parent da6d7518e5
commit 9fcd1741de
4 changed files with 73 additions and 16 deletions

View File

@@ -92,10 +92,10 @@ pub(crate) async fn handle_join_server_req(
return Err("Session not valid".into());
}
let client_id = state.client_id.clone();
let local_id = state.local_id.clone();
let data = SrvJoinServerReply {
result: srv_join_server_reply::Result::Ok,
id: client_id as u32,
id: local_id as u32,
pay_flag: 0,
};
let response_packet = Packet::new(PacketType::PakscJoinServerReply, &data)?;
@@ -170,12 +170,12 @@ pub(crate) async fn handle_login_req(
} else {
debug!("Successfully logged in");
let mut client_id = 0;
let mut local_id = 0;
if let Some(mut state) = connection_service.get_connection_mut(&connection_id) {
state.user_id = Some(response.user_id);
state.session_id = Some(response.session_id.clone());
client_id = connection_service.next_id();
state.client_id = client_id;
local_id = connection_service.next_id();
state.local_id = local_id;
}
let chat_url = format!(
@@ -187,7 +187,7 @@ pub(crate) async fn handle_login_req(
.unwrap()
);
let handler = ChatClientHandler::new(chat_url, client_id.to_string(), response.session_id.clone()).await?;
let handler = ChatClientHandler::new(chat_url, local_id.to_string(), response.session_id.clone()).await?;
let chat_handler = Arc::new(handler);
if let Some(mut state) = connection_service.get_connection_mut(&connection_id) {