fairness localisation
This commit is contained in:
parent
1706f2ac78
commit
57f64ad046
4 changed files with 10 additions and 1 deletions
|
@ -4,6 +4,7 @@ bonus_timeout = 5000
|
|||
event_timeout = 100
|
||||
admin_token = "root"
|
||||
serve_static = true
|
||||
fairness_timeout = 10000
|
||||
teams = [
|
||||
{ id = "team00", name = "Équipe 00", vieux = false},
|
||||
{ id = "team01", name = "Équipe 01", vieux = false},
|
||||
|
|
|
@ -26,6 +26,7 @@ pub struct Config {
|
|||
pub admin_token: String,
|
||||
pub teams: Vec<TeamConfig>,
|
||||
pub serve_static: bool,
|
||||
pub fairness_timeout: u64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
|
@ -114,6 +115,7 @@ pub struct Tracked {
|
|||
pub name: String,
|
||||
pub pos: (f32, f32),
|
||||
pub state: TrackedState,
|
||||
pub last_coord: Instant,
|
||||
}
|
||||
|
||||
pub fn build_conscrit(id: String, name: String) -> Tracked {
|
||||
|
@ -129,6 +131,7 @@ pub fn build_conscrit(id: String, name: String) -> Tracked {
|
|||
invisibility_codes: 0,
|
||||
blur_codes: 0,
|
||||
},
|
||||
last_coord: Instant::now(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,6 +144,7 @@ pub fn build_vieux(id: String, name: String) -> Tracked {
|
|||
invisible: true,
|
||||
color: 1,
|
||||
},
|
||||
last_coord: Instant::now(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,9 @@ fn index() -> &'static str {
|
|||
fn send_coords(tracking: &Tracking, evt_queue: &TrackingEventQueue, config: &Config) {
|
||||
for (id, queue) in evt_queue.iter() {
|
||||
let watcher = tracking.get(id).unwrap().read().unwrap();
|
||||
if watcher.last_coord.elapsed() > Duration::from_millis(config.fairness_timeout) {
|
||||
continue
|
||||
}
|
||||
let mut infos: Vec<TrackedInfo> = Vec::new();
|
||||
for (_, tracked) in tracking.iter() {
|
||||
if let Some(info) =
|
||||
|
|
|
@ -3,7 +3,7 @@ use rocket::{
|
|||
response::stream::{Event, EventStream},
|
||||
tokio::{
|
||||
self, select,
|
||||
time::{self, sleep, Duration},
|
||||
time::{self, sleep, Duration, Instant},
|
||||
},
|
||||
Route, Shutdown, State,
|
||||
};
|
||||
|
@ -80,6 +80,7 @@ fn store_pos(
|
|||
) -> Status {
|
||||
if let Some(tracked) = tracking.get(&id.to_string()) {
|
||||
tracked.write().unwrap().pos = (lat, long);
|
||||
tracked.write().unwrap().last_coord = Instant::now();
|
||||
state_update(&tracked.read().unwrap(), &evt_queues, &admin_queue);
|
||||
Status::Accepted
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue