- fix: user_id and session id were not being saved in the state correctly
- add: server and channel id to connection state
This commit is contained in:
@@ -68,9 +68,9 @@ pub(crate) async fn handle_login_req(stream: &mut TcpStream, packet: Packet, aut
|
||||
} else {
|
||||
debug!("Successfully logged in");
|
||||
|
||||
if let Some(mut state) = connection_service.get_connection(&connection_id) {
|
||||
if let Some(mut state) = connection_service.get_connection_mut(&connection_id) {
|
||||
state.user_id = Some(response.user_id.parse().unwrap());
|
||||
// auth_client.logout(&session_id).await?;
|
||||
state.session_id = Some(response.session_id);
|
||||
}
|
||||
|
||||
let consul_url = env::var("CONSUL_URL").unwrap_or_else(|_| "http://127.0.0.1:8500".to_string());
|
||||
@@ -136,10 +136,15 @@ pub(crate) async fn handle_login_req(stream: &mut TcpStream, packet: Packet, aut
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn handle_server_select_req(stream: &mut TcpStream, packet: Packet) -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
let request = CliSrvSelectReq::decode(packet.payload.as_slice());
|
||||
pub(crate) async fn handle_server_select_req(stream: &mut TcpStream, packet: Packet, connection_service: Arc<ConnectionService>, connection_id: String) -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
let request = CliSrvSelectReq::decode(packet.payload.as_slice())?;
|
||||
debug!("{:?}", request);
|
||||
|
||||
if let Some(mut state) = connection_service.get_connection_mut(&connection_id) {
|
||||
state.additional_data.insert("server".to_string(), request.server_id.to_string());
|
||||
state.additional_data.insert("channel".to_string(), request.channel_id.to_string());
|
||||
}
|
||||
|
||||
let data = SrvSrvSelectReply {
|
||||
result: srv_srv_select_reply::Result::Failed,
|
||||
session_id: 0, // Client should already have this value
|
||||
|
||||
@@ -18,7 +18,7 @@ pub async fn route_packet(stream: &mut TcpStream, packet: Packet, auth_client: A
|
||||
// Login Stuff
|
||||
PacketType::PakcsLoginTokenReq => auth::handle_login_req(stream, packet, auth_client, connection_service, connection_id, stream.peer_addr()?).await,
|
||||
PacketType::PakcsLogoutReq => auth::handle_logout_req(stream, packet, auth_client, connection_service, connection_id).await,
|
||||
PacketType::PakcsSrvSelectReq => auth::handle_server_select_req(stream, packet).await,
|
||||
PacketType::PakcsSrvSelectReq => auth::handle_server_select_req(stream, packet, connection_service, connection_id).await,
|
||||
PacketType::PakcsChannelListReq => auth::handle_channel_list_req(stream, packet).await,
|
||||
|
||||
// Character Stuff
|
||||
|
||||
Reference in New Issue
Block a user