- add: ability to refresh the current session

- add: delete type to delete character request
- add: ability to update key in redis
- add: handle alive packet to refresh the session
- fix: delete now actually returns the time remaining correctly
- fix: character list now has the correct time until character deletion
This commit is contained in:
2025-01-08 02:03:27 -05:00
parent 584892ab97
commit 6d35d15ac3
16 changed files with 158 additions and 25 deletions

View File

@@ -26,6 +26,23 @@ use crate::connection_service::ConnectionService;
use crate::packets::cli_logout_req::CliLogoutReq;
use crate::packets::srv_join_server_reply::SrvJoinServerReply;
pub(crate) async fn handle_alive_req(stream: &mut TcpStream, packet: Packet, auth_client: Arc<Mutex<AuthClient>>, connection_service: Arc<ConnectionService>, connection_id: String) -> Result<(), Box<dyn Error + Send + Sync>> {
if let Some(mut state) = connection_service.get_connection(&connection_id) {
let session_id = state.session_id.clone().unwrap();
debug!("Attempting to refresh session {}", session_id);
let mut auth_client = auth_client.lock().await;
let session = auth_client.refresh_session(&session_id).await?;
if (!session.valid) {
warn!("Invalid session ID: {}", session_id);
return Err("Session not valid".into());
}
Ok(())
} else {
Err("Unable to find connection state".into())
}
}
pub(crate) async fn handle_accept_req(stream: &mut TcpStream, packet: Packet) -> Result<(), Box<dyn Error + Send + Sync>> {
let data = SrvAcceptReply { result: srv_accept_reply::Result::Accepted, rand_value: 0 };
let response_packet = Packet::new(PacketType::PakssAcceptReply, &data)?;