server test is working :)

This commit is contained in:
Rusty Striker 2024-09-30 18:44:36 +03:00
parent 9189d9cd88
commit dd34317d14
Signed by: RustyStriker
GPG key ID: 87E4D691632DFF15
9 changed files with 249 additions and 166 deletions

View file

@ -1,5 +1,34 @@
use game::{Game, GameImpl};
use tokio::sync::{broadcast, mpsc};
pub mod user;
pub mod table;
pub mod api;
pub mod game;
pub mod pathfinder2r_impl;
pub mod pathfinder2r_impl;
pub struct GameServer {
game: Game<pathfinder2r_impl::Pathfinder2rCharacterSheet, pathfinder2r_impl::entry::PEntry>
}
impl GameServer {
pub fn new() -> Self {
Self {
game: Game::new(),
}
}
pub async fn server_loop(mut self, mut msgs: mpsc::Receiver<(String, api::Request)>, mut broadcast: broadcast::Sender<api::Response>) {
while let Some(req) = msgs.recv().await {
// TODO: do stuff yo!
let (id, req) = req;
match req {
api::Request::Error => {},
api::Request::Login(_) => {},
api::Request::Message(msg) => { _ = broadcast.send(api::Response::Message(msg)); },
api::Request::Quit => { _ = broadcast.send(api::Response::Quit { id })},
api::Request::Shutdown => todo!(),
}
}
_ = broadcast.send(api::Response::Shutdown);
}
}