mirror of
https://git.kittycat.homes/zoe/reversi.git
synced 2024-08-15 03:27:19 +00:00
oof
This commit is contained in:
parent
d692ace55f
commit
58066c8abc
1 changed files with 14 additions and 15 deletions
23
src/main.rs
23
src/main.rs
|
@ -6,10 +6,14 @@ extern crate lazy_static;
|
|||
use clap::Parser;
|
||||
|
||||
use rocket::fs::{relative, FileServer};
|
||||
use rocket::response::stream::{Event, EventStream};
|
||||
use rocket_dyn_templates::Template;
|
||||
use rocket::response::stream::{EventStream, Event};
|
||||
|
||||
use std::{collections::HashMap, mem::drop, sync::Mutex};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
mem::drop,
|
||||
sync::{mpsc, Mutex, RwLock},
|
||||
};
|
||||
|
||||
mod names;
|
||||
mod rooms;
|
||||
|
@ -22,7 +26,6 @@ lazy_static! {
|
|||
static ref PLAYS: Mutex<HashMap<String, Vec<rooms::Board>>> = Mutex::new(HashMap::new());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Config options
|
||||
*/
|
||||
|
@ -45,7 +48,7 @@ fn rocket() -> _ {
|
|||
rocket::custom(config)
|
||||
.attach(Template::fairing())
|
||||
.mount("/", FileServer::from(relative!("static")))
|
||||
.mount("/", routes![index, room, stream])
|
||||
.mount("/", routes![index, room, stream, play])
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -118,24 +121,20 @@ async fn room(roomname: &str, token: usize, player1: bool) -> Template {
|
|||
//sends new board if there have been updates
|
||||
//*
|
||||
#[get("/stream/<roomname>/<token>")]
|
||||
fn stream(roomname: String, token: usize) -> EventStream![]{
|
||||
async fn stream(roomname: String, token: usize) -> EventStream![] {
|
||||
let roomlist = ROOMS.lock().unwrap();
|
||||
drop(roomlist);
|
||||
EventStream! {
|
||||
loop {
|
||||
// TODO
|
||||
// check if there are any new events, and then if the room token is correct
|
||||
// if that's the case send the current playing board
|
||||
// otherwise don't do anything
|
||||
let mut i = 0;
|
||||
if i == 0 {
|
||||
let event = "something";
|
||||
yield Event::json(&event);
|
||||
}
|
||||
i += 1
|
||||
yield Event::json(&"oof".to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//*
|
||||
// adds new boards to the send queue after calculating move
|
||||
//*
|
||||
|
|
Loading…
Reference in a new issue