aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/ConnectionManager.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-08-17 17:12:44 +1200
committerGitHub <noreply@github.com>2017-08-17 17:12:44 +1200
commit9e9f97ac34d882594e3d23e959775ce765447787 (patch)
tree775ad2a42ebba160d1e36be38c59384cd1da5a1e /src/org/traccar/database/ConnectionManager.java
parente8739edc4e2b3a945c2b0eeec6286f7ef59037cf (diff)
parent1324c00d0ece6e20545fb75f7775a2c6cee2a391 (diff)
downloadtrackermap-server-9e9f97ac34d882594e3d23e959775ce765447787.tar.gz
trackermap-server-9e9f97ac34d882594e3d23e959775ce765447787.tar.bz2
trackermap-server-9e9f97ac34d882594e3d23e959775ce765447787.zip
Merge pull request #3449 from Abyss777/load_position
Map correct position to delayed event notification
Diffstat (limited to 'src/org/traccar/database/ConnectionManager.java')
-rw-r--r--src/org/traccar/database/ConnectionManager.java21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/org/traccar/database/ConnectionManager.java b/src/org/traccar/database/ConnectionManager.java
index 7a0a6d30d..de11db21b 100644
--- a/src/org/traccar/database/ConnectionManager.java
+++ b/src/org/traccar/database/ConnectionManager.java
@@ -31,6 +31,7 @@ import org.traccar.model.Position;
import java.net.SocketAddress;
import java.sql.SQLException;
import java.util.Date;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -84,7 +85,7 @@ public class ConnectionManager {
if (enableStatusEvents && !status.equals(oldStatus)) {
String eventType;
- Set<Event> events = new HashSet<>();
+ Map<Event, Position> events = new HashMap<>();
switch (status) {
case Device.STATUS_ONLINE:
eventType = Event.TYPE_DEVICE_ONLINE;
@@ -92,18 +93,18 @@ public class ConnectionManager {
case Device.STATUS_UNKNOWN:
eventType = Event.TYPE_DEVICE_UNKNOWN;
if (updateDeviceState) {
- events.addAll(updateDeviceState(deviceId));
+ events.putAll(updateDeviceState(deviceId));
}
break;
default:
eventType = Event.TYPE_DEVICE_OFFLINE;
if (updateDeviceState) {
- events.addAll(updateDeviceState(deviceId));
+ events.putAll(updateDeviceState(deviceId));
}
break;
}
- events.add(new Event(eventType, deviceId));
- Context.getNotificationManager().updateEvents(events, null);
+ events.put(new Event(eventType, deviceId), null);
+ Context.getNotificationManager().updateEvents(events);
}
Timeout timeout = timeouts.remove(deviceId);
@@ -135,19 +136,19 @@ public class ConnectionManager {
updateDevice(device);
}
- public Set<Event> updateDeviceState(long deviceId) {
+ public Map<Event, Position> updateDeviceState(long deviceId) {
DeviceState deviceState = Context.getDeviceManager().getDeviceState(deviceId);
- Set<Event> result = new HashSet<>();
+ Map<Event, Position> result = new HashMap<>();
- Event event = Context.getMotionEventHandler().updateMotionState(deviceState);
+ Map<Event, Position> event = Context.getMotionEventHandler().updateMotionState(deviceState);
if (event != null) {
- result.add(event);
+ result.putAll(event);
}
event = Context.getOverspeedEventHandler().updateOverspeedState(deviceState, Context.getDeviceManager().
lookupAttributeDouble(deviceId, OverspeedEventHandler.ATTRIBUTE_SPEED_LIMIT, 0, false));
if (event != null) {
- result.add(event);
+ result.putAll(event);
}
return result;