More work.

Added chat service
Updated packet service to pass the tcp stream around in a Arc type.
Updated character position data to not require multiplying the coords
Added more debug logs
Added an interceptor for gRPC comms with the chat server
Updated build and push script for the chat server changes
This commit is contained in:
2025-06-06 17:52:29 -04:00
parent 85d41c0239
commit ad6ba2c8e6
32 changed files with 787 additions and 92 deletions

View File

@@ -7,7 +7,9 @@ use std::error::Error;
use std::sync::Arc;
use tokio::net::TcpStream;
use tokio::sync::Mutex;
use tonic::transport::Channel;
use tracing::debug;
use utils::service_discovery::get_kube_service_endpoints_by_dns;
fn distance(x1: f64, y1: f64, x2: f64, y2: f64) -> u16 {
let dist = ((x2 - x1).powi(2) + (y2 - y1).powi(2)).sqrt();
@@ -15,7 +17,7 @@ fn distance(x1: f64, y1: f64, x2: f64, y2: f64) -> u16 {
}
pub(crate) async fn handle_change_map_req(
stream: &mut TcpStream,
stream: Arc<Mutex<TcpStream>>,
packet: Packet,
character_client: Arc<Mutex<CharacterClient>>,
connection_service: Arc<ConnectionService>,
@@ -64,13 +66,14 @@ pub(crate) async fn handle_change_map_req(
team_number: 10,
};
let response_packet = Packet::new(PacketType::PakwcChangeMapReply, &data)?;
send_packet(stream, &response_packet).await?;
let mut locked_stream = stream.lock().await;
send_packet(&mut locked_stream, &response_packet).await?;
Ok(())
}
pub(crate) async fn handle_mouse_cmd_req(
stream: &mut TcpStream,
stream: Arc<Mutex<TcpStream>>,
packet: Packet,
connection_service: Arc<ConnectionService>,
connection_id: String,
@@ -96,6 +99,7 @@ pub(crate) async fn handle_mouse_cmd_req(
z: request.z,
};
let response_packet = Packet::new(PacketType::PakwcMouseCmd, &data)?;
send_packet(stream, &response_packet).await?;
let mut locked_stream = stream.lock().await;
send_packet(&mut locked_stream, &response_packet).await?;
Ok(())
}