gen,
u : UpdatePayload::PieceUpdate(piece, p.mk_update()),
};
+ let update = Arc::new(update);
+ // split vie wthing would go here
p.gen_lastclient = gen;
- for (tclient, tcl) in &mut g.clients {
- if tclient == client {
- tcl.transmit_update(&Update {
- gen,
- u : UpdatePayload::ClientSequence(piece, form.s),
- });
- } else {
- tcl.transmit_update(&update);
- }
+ for (_tplayer, tplupdates) in &mut g.updates {
+ tplupdates.log.push_back((client, update.clone()));
+ tplupdates.cv.notify_all();
}
Ok(())
})();
#[derive(Debug)]
struct TestCounterInner { next : usize, }
impl Read for TestCounterInner {
+
+
+ /*
+ for (tclient, tcl) in &mut g.clients {
+ if tclient == client {
+ tcl.transmit_update(&Update {
+ gen,
+ u : UpdatePayload::ClientSequence(piece, form.s),
+ });
+ } else {
+ tcl.transmit_update(&update);
+ }
+ }
+ */
+
+
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
thread::sleep(Duration::from_millis(500));
let message = XUpdate::TestCounter { value : self.next };
}
}
+pub struct PlayerUpdates {
+ pub log : VecDeque<(ClientId, Arc<Update>)>,
+ pub cv : Condvar,
+}
+
pub struct Instance {
pub gs : GameState,
pub clients : DenseSlotMap<ClientId,Client>,
+ pub updates : SecondarySlotMap<PlayerId, PlayerUpdates>,
}
#[derive(Clone)]
let gi = Instance {
gs : xxx_gamestate_init(),
clients : Default::default(),
+ updates : Default::default(),
};
let g = Arc::new(Mutex::new(gi));
let mut ig = g.lock().unwrap();
pub use std::fmt::{self,Display,Debug};
pub use std::thread;
pub use std::time::Duration;
-pub use std::sync::{Arc,Mutex,RwLock};
+pub use std::sync::{Arc,Mutex,RwLock,Condvar};
pub use std::collections::HashMap;
pub use std::borrow::Borrow;
pub use std::convert::TryFrom;
pub use std::str::FromStr;
pub use std::iter::repeat_with;
+pub use std::collections::VecDeque;
pub use thiserror::Error;
pub use anyhow::{Context,anyhow};