diff options
Diffstat (limited to 'src/main/java/org/traccar/session')
-rw-r--r-- | src/main/java/org/traccar/session/ConnectionManager.java | 34 | ||||
-rw-r--r-- | src/main/java/org/traccar/session/DeviceState.java | 18 |
2 files changed, 11 insertions, 41 deletions
diff --git a/src/main/java/org/traccar/session/ConnectionManager.java b/src/main/java/org/traccar/session/ConnectionManager.java index 262a302af..c826b99db 100644 --- a/src/main/java/org/traccar/session/ConnectionManager.java +++ b/src/main/java/org/traccar/session/ConnectionManager.java @@ -15,7 +15,6 @@ */ package org.traccar.session; -import com.google.inject.Injector; import io.netty.channel.Channel; import io.netty.util.Timeout; import io.netty.util.Timer; @@ -28,9 +27,6 @@ import org.traccar.config.Config; import org.traccar.config.Keys; import org.traccar.database.DeviceLookupService; import org.traccar.database.NotificationManager; -import org.traccar.handler.events.MotionEventHandler; -import org.traccar.handler.events.OverspeedEventHandler; -import org.traccar.helper.model.AttributeUtil; import org.traccar.model.BaseModel; import org.traccar.model.Device; import org.traccar.model.Event; @@ -66,14 +62,12 @@ public class ConnectionManager implements BroadcastInterface { private static final Logger LOGGER = LoggerFactory.getLogger(ConnectionManager.class); private final long deviceTimeout; - private final boolean updateDeviceState; 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 Injector injector; private final Config config; private final CacheManager cacheManager; private final Storage storage; @@ -90,10 +84,9 @@ public class ConnectionManager implements BroadcastInterface { @Inject public ConnectionManager( - Injector injector, Config config, CacheManager cacheManager, Storage storage, + Config config, CacheManager cacheManager, Storage storage, NotificationManager notificationManager, Timer timer, BroadcastService broadcastService, DeviceLookupService deviceLookupService) { - this.injector = injector; this.config = config; this.cacheManager = cacheManager; this.storage = storage; @@ -102,7 +95,6 @@ public class ConnectionManager implements BroadcastInterface { this.broadcastService = broadcastService; this.deviceLookupService = deviceLookupService; deviceTimeout = config.getLong(Keys.STATUS_TIMEOUT); - updateDeviceState = config.getBoolean(Keys.STATUS_UPDATE_DEVICE_STATE); broadcastService.registerListener(this); } @@ -246,15 +238,9 @@ public class ConnectionManager implements BroadcastInterface { break; case Device.STATUS_UNKNOWN: eventType = Event.TYPE_DEVICE_UNKNOWN; - if (updateDeviceState) { - events.putAll(updateDeviceState(deviceId)); - } break; default: eventType = Event.TYPE_DEVICE_OFFLINE; - if (updateDeviceState) { - events.putAll(updateDeviceState(deviceId)); - } break; } events.put(new Event(eventType, deviceId), null); @@ -297,24 +283,6 @@ public class ConnectionManager implements BroadcastInterface { deviceStates.put(deviceId, deviceState); } - public Map<Event, Position> updateDeviceState(long deviceId) { - DeviceState deviceState = getDeviceState(deviceId); - Map<Event, Position> result = new HashMap<>(); - - Map<Event, Position> event = injector.getInstance(MotionEventHandler.class).updateMotionState(deviceState); - if (event != null) { - result.putAll(event); - } - - double speedLimit = AttributeUtil.lookup(cacheManager, Keys.EVENT_OVERSPEED_LIMIT, deviceId); - event = injector.getInstance(OverspeedEventHandler.class).updateOverspeedState(deviceState, speedLimit); - if (event != null) { - result.putAll(event); - } - - return result; - } - public synchronized void sendKeepalive() { for (Set<UpdateListener> userListeners : listeners.values()) { for (UpdateListener listener : userListeners) { diff --git a/src/main/java/org/traccar/session/DeviceState.java b/src/main/java/org/traccar/session/DeviceState.java index b7248688a..f67b906c4 100644 --- a/src/main/java/org/traccar/session/DeviceState.java +++ b/src/main/java/org/traccar/session/DeviceState.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2022 Anton Tananaev (anton@traccar.org) * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,6 +18,8 @@ package org.traccar.session; import org.traccar.model.Position; +import java.util.Date; + public class DeviceState { private Boolean motionState; @@ -40,24 +42,24 @@ public class DeviceState { return motionPosition; } - private Boolean overspeedState; + private boolean overspeedState; public void setOverspeedState(boolean overspeedState) { this.overspeedState = overspeedState; } - public Boolean getOverspeedState() { + public boolean getOverspeedState() { return overspeedState; } - private Position overspeedPosition; + private Date overspeedTime; - public void setOverspeedPosition(Position overspeedPosition) { - this.overspeedPosition = overspeedPosition; + public Date getOverspeedTime() { + return overspeedTime; } - public Position getOverspeedPosition() { - return overspeedPosition; + public void setOverspeedTime(Date overspeedTime) { + this.overspeedTime = overspeedTime; } private long overspeedGeofenceId; |