34 lines
No EOL
1 KiB
Rust
34 lines
No EOL
1 KiB
Rust
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 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);
|
|
}
|
|
} |