Skip to content

Commit

Permalink
fix: add +1ms to get rid of 20s afk-events not being merged by heartb…
Browse files Browse the repository at this point in the history
…eat (#64)

Discovered that whenever I got afk, there was a 20s AFK event, and also
a however long AFK event (longer than 20s) starting at the same time.
Upon closer inspection they were 1ms off, which this fixes.
  • Loading branch information
ErikBjare authored Nov 18, 2023
1 parent 0e356fe commit 84dd679
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion aw_watcher_afk/afk.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@ def heartbeat_loop(self):
# Send a heartbeat if no state change was made
else:
if afk:
# we need the +1ms here too, to make sure we don't "miss" the last heartbeat
# (if last_input hasn't changed)
self.ping(
afk, timestamp=last_input, duration=seconds_since_input
afk,
timestamp=last_input + td1ms,
duration=seconds_since_input,
)
else:
self.ping(afk, timestamp=last_input)
Expand Down

0 comments on commit 84dd679

Please sign in to comment.