diff options
Diffstat (limited to 'server/src/main.rs')
-rw-r--r-- | server/src/main.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/server/src/main.rs b/server/src/main.rs index f688cffe..06786c05 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -1,7 +1,5 @@ use anyhow::Result; -use game::Game; -use log::info; -use protocol::{PacketC, PacketS}; +use log::{debug, info}; use std::{sync::Arc, time::Duration}; use tokio::{ io::{AsyncBufReadExt, AsyncWriteExt, BufReader}, @@ -10,9 +8,10 @@ use tokio::{ sync::{broadcast, RwLock}, time::sleep, }; - -pub mod game; -pub mod protocol; +use undercooked::{ + game::Game, + protocol::{PacketC, PacketS}, +}; #[tokio::main] async fn main() -> Result<()> { @@ -29,6 +28,7 @@ async fn main() -> Result<()> { { let mut g = game.write().await; while let Some(p) = g.packet_out() { + debug!("-> {p:?}"); let _ = tx.send(p); } } @@ -48,12 +48,14 @@ async fn main() -> Result<()> { .write_all(serde_json::to_string(&packet).unwrap().as_bytes()) .await .unwrap(); + write.write_all(b"\n").await.unwrap(); } }); spawn(async move { let mut read = BufReader::new(read).lines(); while let Ok(Some(line)) = read.next_line().await { let packet: PacketS = serde_json::from_str(&line).unwrap(); + debug!("<- {id} {packet:?}"); game.write().await.packet_in(id, packet).unwrap(); } }); |