server test is working :)
This commit is contained in:
parent
9189d9cd88
commit
dd34317d14
9 changed files with 249 additions and 166 deletions
31
src/lib.rs
31
src/lib.rs
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue