add a bit more logging

This commit is contained in:
Nikita Vilunov 2023-09-23 01:12:03 +02:00
parent 3d59f6aae5
commit df6cdd4861
2 changed files with 7 additions and 3 deletions

View File

@ -52,6 +52,7 @@ async fn handle_socket(
termination: Deferred<()>, // TODO use it to stop the connection gracefully termination: Deferred<()>, // TODO use it to stop the connection gracefully
mut storage: Storage, mut storage: Storage,
) -> Result<()> { ) -> Result<()> {
log::info!("Received an IRC connection from {socket_addr}");
let (reader, writer) = stream.split(); let (reader, writer) = stream.split();
let mut reader: BufReader<ReadHalf> = BufReader::new(reader); let mut reader: BufReader<ReadHalf> = BufReader::new(reader);
let mut writer = BufWriter::new(writer); let mut writer = BufWriter::new(writer);
@ -74,10 +75,13 @@ async fn handle_socket(
match registered_user { match registered_user {
Ok(user) => { Ok(user) => {
log::debug!("User registered");
handle_registered_socket(config, players, rooms, &mut reader, &mut writer, user) handle_registered_socket(config, players, rooms, &mut reader, &mut writer, user)
.await?; .await?;
} }
Err(_) => {} Err(_) => {
log::debug!("Registration failed");
}
} }
stream.shutdown().await?; stream.shutdown().await?;

View File

@ -149,7 +149,7 @@ async fn handle_socket(
rooms: RoomRegistry, rooms: RoomRegistry,
termination: Deferred<()>, // TODO use it to stop the connection gracefully termination: Deferred<()>, // TODO use it to stop the connection gracefully
) -> Result<()> { ) -> Result<()> {
log::debug!("Received an XMPP connection from {socket_addr}"); log::info!("Received an XMPP connection from {socket_addr}");
let mut reader_buf = vec![]; let mut reader_buf = vec![];
let (reader, writer) = stream.split(); let (reader, writer) = stream.split();
let mut buf_reader = BufReader::new(reader); let mut buf_reader = BufReader::new(reader);
@ -172,6 +172,7 @@ async fn handle_socket(
let mut xml_writer = Writer::new(b); let mut xml_writer = Writer::new(b);
let authenticated = socket_auth(&mut xml_reader, &mut xml_writer, &mut reader_buf).await?; let authenticated = socket_auth(&mut xml_reader, &mut xml_writer, &mut reader_buf).await?;
log::debug!("User authenticated");
let mut connection = players let mut connection = players
.connect_to_player(authenticated.player_id.clone()) .connect_to_player(authenticated.player_id.clone())
.await; .await;
@ -314,7 +315,6 @@ async fn socket_final(
match parser.consume(ns, &event) { match parser.consume(ns, &event) {
Continuation::Final(res) => { Continuation::Final(res) => {
let res = res?; let res = res?;
dbg!(&res);
let stop = handle_packet(&mut events, res, authenticated, user_handle, rooms).await?; let stop = handle_packet(&mut events, res, authenticated, user_handle, rooms).await?;
for i in &events { for i in &events {
xml_writer.write_event_async(i).await?; xml_writer.write_event_async(i).await?;