Make federation feed only report changes

This commit is contained in:
Sakuhl 2018-04-04 13:08:52 +02:00
parent efdc559fc0
commit 4655e43dba

View File

@ -97,6 +97,9 @@ pub fn federation_livefeed() {
let mut territories: Value = serde_json::from_reader(resp).unwrap(); let mut territories: Value = serde_json::from_reader(resp).unwrap();
let mut old_owned = vec![];
let mut old_owned_ffa = vec![];
let mut timestamp = territories.as_object().unwrap().get("request").unwrap().as_object().unwrap().get("timestamp").unwrap().as_u64().unwrap(); let mut timestamp = territories.as_object().unwrap().get("request").unwrap().as_object().unwrap().get("timestamp").unwrap().as_u64().unwrap();
loop { loop {
@ -126,14 +129,18 @@ pub fn federation_livefeed() {
} }
} }
for listener in federationfeed_listeners if old_owned != assigned_owned_by_enemies || old_owned_ffa != ffa_owned_by_enemies {
.load::<FederationfeedListener>(&connection) for listener in federationfeed_listeners
.expect("Error loading listeners") { .load::<FederationfeedListener>(&connection)
let _ = ChannelId(listener.id as u64).say(format!("Assigned owned by others: {:?} .expect("Error loading listeners") {
let _ = ChannelId(listener.id as u64).say(format!("Assigned owned by others: {:?}
FFA owned by others: {:?}", FFA owned by others: {:?}",
assigned_owned_by_enemies, assigned_owned_by_enemies,
ffa_owned_by_enemies ffa_owned_by_enemies
)); ));
}
old_owned = assigned_owned_by_enemies;
old_owned_ffa = ffa_owned_by_enemies;
} }
territories = new_territories; territories = new_territories;