Skip to content

Commit

Permalink
Merge pull request #42 from drifting-in-space/paulgb/version-updates
Browse files Browse the repository at this point in the history
Fix timer
  • Loading branch information
paulgb committed May 5, 2024
2 parents 09b3b5c + edbaeb1 commit 1f33689
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions aper-stateroom/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ impl<P: StateProgram + Default> AperStateroomService<P> {
}

if let Some(ev) = &susp {
if let Ok(dur) = ev.timestamp.signed_duration_since(Utc::now()).to_std() {
ctx.set_timer(dur.as_millis() as u32);
}
let dur = ev.timestamp.signed_duration_since(Utc::now());
ctx.set_timer(dur.num_milliseconds().max(0) as u32);
}

self.suspended_event = susp;
Expand Down Expand Up @@ -125,6 +124,10 @@ impl<P: StateProgram + Default> StateroomService for AperStateroomService<P>
where
P::T: Unpin + Send + Sync + 'static,
{
fn init(&mut self, ctx: &impl StateroomContext) {
self.update_suspended_event(ctx);
}

fn connect(&mut self, client_id: ClientId, ctx: &impl StateroomContext) {
let response = StateProgramMessage::InitialState {
timestamp: Utc::now(),
Expand Down

0 comments on commit 1f33689

Please sign in to comment.