Live location tracking and playback for the game "manhunt"

Signaling dont disconnect with host after started

bwc9876.dev 75fd7580 e596a1ed

verified
+22 -2
+1 -1
TODO.md
··· 26 26 - [x] Lobby tests 27 27 - [x] Game end test for actual return from loop 28 28 - [x] More transport crate tests 29 - - [ ] Signaling is wrong, only kick everyone else on host leave if the lobby is open 29 + - [x] Signaling is wrong, only kick everyone else on host leave if the lobby is open 30 30 - [x] Organize signalling and seperate out more logic 31 31 - [x] Signaling tests 32 32 - [ ] Testing crate for integration testing?
+21 -1
manhunt-signaling/src/state.rs
··· 223 223 .unwrap_or_default(); 224 224 225 225 if host { 226 - if let Some(mat) = matches.get_mut(&removed_peer.room) { 226 + if let Some(mat) = matches.get_mut(&removed_peer.room).filter(|m| m.open_lobby) { 227 227 // If we're host, disconnect everyone else 228 228 mat.open_lobby = false; 229 229 mat.cancel.cancel(); ··· 458 458 let matches = state.matches.lock().unwrap(); 459 459 let mat = &matches[&code.to_string()]; 460 460 assert!(mat.cancel.is_cancelled()); 461 + assert!(!mat.open_lobby); 462 + } 463 + 464 + #[test] 465 + fn test_host_leave_with_players_but_started() { 466 + let mut state = ServerState::default(); 467 + 468 + let code = "asdfasdfasdfasdf"; 469 + 470 + quick_create(&mut state, code, 1); 471 + quick_join(&mut state, code, 2); 472 + 473 + state.mark_started(&code.to_string()); 474 + 475 + let others = state.remove_peer(peer(1), true); 476 + 477 + assert_eq!(others, Some(vec![peer(2)])); 478 + let matches = state.matches.lock().unwrap(); 479 + let mat = &matches[&code.to_string()]; 480 + assert!(!mat.cancel.is_cancelled()); 461 481 assert!(!mat.open_lobby); 462 482 } 463 483