Skip to content

Commit

Permalink
For #256 - detect whether device is offline not just by the device ti…
Browse files Browse the repository at this point in the history
…me but by the server time as well
  • Loading branch information
vitalidze committed Sep 30, 2015
1 parent a37ce0d commit 975b6c0
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public void doWork() {
}

// check that device is offline
if (currentTime.getTime() - device.getLatestPosition().getTime().getTime() >= device.getTimeout() * 1000) {
if (currentTime.getTime() - device.getLatestPosition().getTime().getTime() >= device.getTimeout() * 1000
&& (device.getLatestPosition().getServerTime() == null || device.getLatestPosition().getServerTime().getTime() >= device.getTimeout() * 1000)) {
List<DeviceEvent> offlineEvents = entityManager.get().createQuery("SELECT e FROM DeviceEvent e WHERE e.position=:position AND e.type=:offline")
.setParameter("position", device.getLatestPosition())
.setParameter("offline", DeviceEventType.OFFLINE)
Expand Down

0 comments on commit 975b6c0

Please sign in to comment.