aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/session/ConnectionManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/session/ConnectionManager.java')
-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()