cleanup
This commit is contained in:
parent
880bab0ae2
commit
30d4388063
5 changed files with 6 additions and 6 deletions
|
@ -31,7 +31,7 @@ pub async fn websocket(stream: WebSocket, state: Arc<AppState>, who: SocketAddr)
|
|||
let mut rx = state.tx.subscribe();
|
||||
|
||||
// ANNOUNCE THY PRESENCE
|
||||
let msg = format!("{who} is here, bitches!");
|
||||
let msg = format!("{who} joined.");
|
||||
tracing::debug!("{msg}");
|
||||
let _ = state.tx.send(msg);
|
||||
|
||||
|
|
|
@ -31,12 +31,11 @@ pub async fn message_handler(message: Message, state: &Arc<AppState>, who: Socke
|
|||
|
||||
match message {
|
||||
Message::Text(text) => {
|
||||
tracing::debug!("{who}: {}", text);
|
||||
|
||||
if let Ok(new_game) = serde_json::from_str::<NewGameRequest>(&text) {
|
||||
tracing::debug!("{:#?}", &new_game);
|
||||
// create game
|
||||
if let Ok(new_game_object) = CAHGame::new(new_game) {
|
||||
let _ = tx.send(format!("{:#?}", &new_game_object.players[0].white));
|
||||
state.games.lock().unwrap().push(new_game_object);
|
||||
let _update = tx.send(greeting(&state));
|
||||
} else {
|
||||
|
|
|
@ -17,12 +17,13 @@ use crate::message_handler::*;
|
|||
|
||||
/// Parse json for card data
|
||||
fn load_json(path: &str) -> Result<Vec<CAHCardSet>, Box<dyn Error>> {
|
||||
let data: String = fs::read_to_string(path).expect("Error reading file");
|
||||
let data: String = fs::read_to_string(path)?;
|
||||
let jayson: Vec<CAHCardSet> = serde_json::from_str(&data)?;
|
||||
|
||||
Ok(jayson)
|
||||
}
|
||||
|
||||
// this is still around just for reference
|
||||
#[allow(dead_code)]
|
||||
fn test() -> Result<(), Box<dyn Error>> {
|
||||
// choose decks
|
||||
|
@ -88,10 +89,10 @@ pub struct AppState {
|
|||
|
||||
// Include utf-8 files at **compile** time.
|
||||
async fn index() -> Html<&'static str> {
|
||||
Html(std::include_str!("../test_client.html"))
|
||||
Html(std::include_str!("../public/test_client.html"))
|
||||
}
|
||||
async fn spawnclients() -> Html<&'static str> {
|
||||
Html(std::include_str!("../spawnclients.html"))
|
||||
Html(std::include_str!("../public/spawnclients.html"))
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
|
|
Loading…
Add table
Reference in a new issue