aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/session
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-18 13:19:53 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-18 13:19:53 -0700
commit3a293661cd2900c115cfea6037c02d659c57aa52 (patch)
treede6f5f187af17b0272654016a6c2049c98f67d9a /src/main/java/org/traccar/session
parent589582c7ecc0d1cd5321cb6e9f4b823284369498 (diff)
downloadtrackermap-server-3a293661cd2900c115cfea6037c02d659c57aa52.tar.gz
trackermap-server-3a293661cd2900c115cfea6037c02d659c57aa52.tar.bz2
trackermap-server-3a293661cd2900c115cfea6037c02d659c57aa52.zip
Move device status
Diffstat (limited to 'src/main/java/org/traccar/session')
-rw-r--r--src/main/java/org/traccar/session/ConnectionManager.java17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/session/ConnectionManager.java b/src/main/java/org/traccar/session/ConnectionManager.java
index 38d82e848..cead771c9 100644
--- a/src/main/java/org/traccar/session/ConnectionManager.java
+++ b/src/main/java/org/traccar/session/ConnectionManager.java
@@ -20,7 +20,6 @@ import io.netty.util.Timeout;
import io.netty.util.Timer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.traccar.Context;
import org.traccar.Main;
import org.traccar.Protocol;
import org.traccar.config.Config;
@@ -63,6 +62,8 @@ public class ConnectionManager {
private final Map<Long, DeviceSession> sessionsByDeviceId = new ConcurrentHashMap<>();
private final Map<Endpoint, Map<String, DeviceSession>> sessionsByEndpoint = new ConcurrentHashMap<>();
+ private final Map<Long, DeviceState> deviceStates = new ConcurrentHashMap<>();
+
private final Config config;
private final CacheManager cacheManager;
private final Storage storage;
@@ -256,7 +257,9 @@ public class ConnectionManager {
}
try {
- Context.getDeviceManager().updateDeviceStatus(device);
+ storage.updateObject(device, new Request(
+ new Columns.Include("lastUpdate"),
+ new Condition.Equals("id", "id")));
} catch (StorageException e) {
LOGGER.warn("Update device status error", e);
}
@@ -264,8 +267,16 @@ public class ConnectionManager {
updateDevice(device);
}
+ public DeviceState getDeviceState(long deviceId) {
+ return deviceStates.computeIfAbsent(deviceId, x -> new DeviceState());
+ }
+
+ public void setDeviceState(long deviceId, DeviceState deviceState) {
+ deviceStates.put(deviceId, deviceState);
+ }
+
public Map<Event, Position> updateDeviceState(long deviceId) {
- DeviceState deviceState = Context.getDeviceManager().getDeviceState(deviceId);
+ DeviceState deviceState = getDeviceState(deviceId);
Map<Event, Position> result = new HashMap<>();
Map<Event, Position> event = Main.getInjector()