aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/handler/events
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/handler/events')
-rw-r--r--src/main/java/org/traccar/handler/events/GeofenceEventHandler.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java b/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java
index f4807e56b..dae0c891f 100644
--- a/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2021 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ import java.util.Map;
import io.netty.channel.ChannelHandler;
import org.traccar.database.CalendarManager;
+import org.traccar.database.ConnectionManager;
import org.traccar.database.GeofenceManager;
import org.traccar.database.IdentityManager;
import org.traccar.model.Calendar;
@@ -35,12 +36,15 @@ public class GeofenceEventHandler extends BaseEventHandler {
private final IdentityManager identityManager;
private final GeofenceManager geofenceManager;
private final CalendarManager calendarManager;
+ private final ConnectionManager connectionManager;
public GeofenceEventHandler(
- IdentityManager identityManager, GeofenceManager geofenceManager, CalendarManager calendarManager) {
+ IdentityManager identityManager, GeofenceManager geofenceManager, CalendarManager calendarManager,
+ ConnectionManager connectionManager) {
this.identityManager = identityManager;
this.geofenceManager = geofenceManager;
this.calendarManager = calendarManager;
+ this.connectionManager = connectionManager;
}
@Override
@@ -63,6 +67,9 @@ public class GeofenceEventHandler extends BaseEventHandler {
oldGeofences.removeAll(currentGeofences);
device.setGeofenceIds(currentGeofences);
+ if (!oldGeofences.isEmpty() || !newGeofences.isEmpty()) {
+ connectionManager.updateDevice(device);
+ }
Map<Event, Position> events = new HashMap<>();
for (long geofenceId : oldGeofences) {