1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-04-26 16:37:46 +00:00
kawari/src/bin/kawari-lobby.rs

29 lines
713 B
Rust
Raw Normal View History

2025-03-08 13:58:24 -05:00
use kawari::packet::parse_packet;
use tokio::io::AsyncReadExt;
use tokio::net::TcpListener;
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
let listener = TcpListener::bind("127.0.0.1:7000").await.unwrap();
tracing::info!("Lobby server started on 7000");
loop {
let (socket, _) = listener.accept().await.unwrap();
let (mut read, _) = tokio::io::split(socket);
tokio::spawn(async move {
let mut buf = [0; 2056];
loop {
let n = read.read(&mut buf).await.expect("Failed to read data!");
if n != 0 {
parse_packet(&buf[..n]);
}
}
});
}
}