aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/session/ConnectionManager.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-07-12 17:31:36 -0700
committerAnton Tananaev <anton@traccar.org>2022-07-12 17:31:36 -0700
commit493ff1068ea3e4d96f2475234b265b47cce8691f (patch)
tree6de7dbc5ac202ba576bc04ecf45dab751aee7bfd /src/main/java/org/traccar/session/ConnectionManager.java
parent98e2db95f73cb85a2623e2902741bcb4e73683e5 (diff)
downloadtrackermap-server-493ff1068ea3e4d96f2475234b265b47cce8691f.tar.gz
trackermap-server-493ff1068ea3e4d96f2475234b265b47cce8691f.tar.bz2
trackermap-server-493ff1068ea3e4d96f2475234b265b47cce8691f.zip
Persist device status (fix #4890, fix #4891)
Diffstat (limited to 'src/main/java/org/traccar/session/ConnectionManager.java')
-rw-r--r--src/main/java/org/traccar/session/ConnectionManager.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/session/ConnectionManager.java b/src/main/java/org/traccar/session/ConnectionManager.java
index d4bb9b4b1..62fdd833b 100644
--- a/src/main/java/org/traccar/session/ConnectionManager.java
+++ b/src/main/java/org/traccar/session/ConnectionManager.java
@@ -52,6 +52,7 @@ import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
@@ -256,15 +257,15 @@ public class ConnectionManager implements BroadcastInterface {
notificationManager.updateEvents(events);
}
+ if (time != null) {
+ device.setLastUpdate(time);
+ }
+
Timeout timeout = timeouts.remove(deviceId);
if (timeout != null) {
timeout.cancel();
}
- if (time != null) {
- device.setLastUpdate(time);
- }
-
if (status.equals(Device.STATUS_ONLINE)) {
timeouts.put(deviceId, timer.newTimeout(timeout1 -> {
if (!timeout1.isCancelled()) {
@@ -275,7 +276,7 @@ public class ConnectionManager implements BroadcastInterface {
try {
storage.updateObject(device, new Request(
- new Columns.Include("lastUpdate"),
+ new Columns.Include("status", "lastUpdate"),
new Condition.Equals("id", "id")));
} catch (StorageException e) {
LOGGER.warn("Update device status error", e);
@@ -368,7 +369,7 @@ public class ConnectionManager implements BroadcastInterface {
if (clazz1.equals(User.class) && clazz2.equals(Device.class)) {
if (listeners.containsKey(id1)) {
userDevices.get(id1).add(id2);
- deviceUsers.put(id2, Set.of(id1));
+ deviceUsers.put(id2, new HashSet<>(List.of(id1)));
}
}
}