diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-06-24 21:38:32 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-24 21:38:32 +1200 |
commit | 5b254b93fef12f39b0782bbc94d5f280e680900c (patch) | |
tree | c2296ba2461ffc7d33bebb034468e56a5511defc | |
parent | 25e323de26718d349999873196bc5c3f5d70eaae (diff) | |
parent | 52e7002ed39c333884529c3a0e8b4c6d23f0115e (diff) | |
download | trackermap-server-5b254b93fef12f39b0782bbc94d5f280e680900c.tar.gz trackermap-server-5b254b93fef12f39b0782bbc94d5f280e680900c.tar.bz2 trackermap-server-5b254b93fef12f39b0782bbc94d5f280e680900c.zip |
Merge pull request #2044 from Abyss777/master
Possibility to disable event and geofences
-rw-r--r-- | debug.xml | 3 | ||||
-rw-r--r-- | setup/unix/traccar.xml | 2 | ||||
-rw-r--r-- | setup/windows/traccar.xml | 2 | ||||
-rw-r--r-- | src/org/traccar/BaseEventHandler.java | 6 | ||||
-rw-r--r-- | src/org/traccar/BasePipelineFactory.java | 16 | ||||
-rw-r--r-- | src/org/traccar/Context.java | 8 | ||||
-rw-r--r-- | src/org/traccar/database/ConnectionManager.java | 4 | ||||
-rw-r--r-- | src/org/traccar/database/NotificationManager.java | 4 |
8 files changed, 27 insertions, 18 deletions
@@ -41,6 +41,8 @@ <entry key='logger.level'>all</entry> <entry key='logger.file'>target/tracker-server.log</entry> + <entry key='event.enable'>true</entry> + <entry key='event.suppressRepeated'>60</entry> <entry key='event.overspeedHandler'>true</entry> @@ -48,7 +50,6 @@ <entry key='event.motionHandler'>true</entry> - <entry key='event.geofenceHandler'>true</entry> <!-- DATABASE CONFIG --> diff --git a/setup/unix/traccar.xml b/setup/unix/traccar.xml index ab739e4d6..b75376434 100644 --- a/setup/unix/traccar.xml +++ b/setup/unix/traccar.xml @@ -17,6 +17,8 @@ <entry key='logger.level'>all</entry> <entry key='logger.file'>/opt/traccar/logs/tracker-server.log</entry> + <entry key='event.enable'>true</entry> + <entry key='event.suppressRepeated'>60</entry> <entry key='event.overspeedHandler'>true</entry> diff --git a/setup/windows/traccar.xml b/setup/windows/traccar.xml index 17f2ab4f3..995b52c0d 100644 --- a/setup/windows/traccar.xml +++ b/setup/windows/traccar.xml @@ -17,6 +17,8 @@ <entry key='logger.level'>all</entry>
<entry key='logger.file'>[LOG]</entry>
+ <entry key='event.enable'>true</entry>
+
<entry key='event.suppressRepeated'>60</entry>
<entry key='event.overspeedHandler'>true</entry>
diff --git a/src/org/traccar/BaseEventHandler.java b/src/org/traccar/BaseEventHandler.java index 1ae9d2c6d..82e78c6b3 100644 --- a/src/org/traccar/BaseEventHandler.java +++ b/src/org/traccar/BaseEventHandler.java @@ -26,10 +26,8 @@ public abstract class BaseEventHandler extends BaseDataHandler { protected Position handlePosition(Position position) { Collection<Event> events = analyzePosition(position); - if (events != null) { - for (Event event : events) { - Context.getNotificationManager().updateEvent(event, position); - } + if (events != null && Context.getNotificationManager() != null) { + Context.getNotificationManager().updateEvents(events, position); } return position; } diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java index b61d95171..44f1b0657 100644 --- a/src/org/traccar/BasePipelineFactory.java +++ b/src/org/traccar/BasePipelineFactory.java @@ -132,20 +132,20 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { hemisphereHandler = new HemisphereHandler(); } - commandResultEventHandler = new CommandResultEventHandler(); + if (Context.getConfig().getBoolean("event.enable")) { + commandResultEventHandler = new CommandResultEventHandler(); - if (Context.getConfig().getBoolean("event.overspeedHandler")) { - overspeedEventHandler = new OverspeedEventHandler(); - } + if (Context.getConfig().getBoolean("event.overspeedHandler")) { + overspeedEventHandler = new OverspeedEventHandler(); + } - if (Context.getConfig().getBoolean("event.motionHandler")) { - motionEventHandler = new MotionEventHandler(); + if (Context.getConfig().getBoolean("event.motionHandler")) { + motionEventHandler = new MotionEventHandler(); + } } - if (Context.getConfig().getBoolean("event.geofenceHandler")) { geofenceEventHandler = new GeofenceEventHandler(); } - } protected abstract void addSpecificHandlers(ChannelPipeline pipeline); diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index f40db72e5..b37e87331 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -193,9 +193,13 @@ public final class Context { connectionManager = new ConnectionManager(dataManager); - geofenceManager = new GeofenceManager(dataManager); + if (config.getBoolean("event.geofenceHandler")) { + geofenceManager = new GeofenceManager(dataManager); + } - notificationManager = new NotificationManager(dataManager); + if (config.getBoolean("event.enable")) { + notificationManager = new NotificationManager(dataManager); + } serverManager = new ServerManager(); diff --git a/src/org/traccar/database/ConnectionManager.java b/src/org/traccar/database/ConnectionManager.java index 8a1debdfa..8796673b1 100644 --- a/src/org/traccar/database/ConnectionManager.java +++ b/src/org/traccar/database/ConnectionManager.java @@ -94,7 +94,9 @@ public class ConnectionManager { if (status.equals(Device.STATUS_ONLINE)) { event.setType(Event.TYPE_DEVICE_ONLINE); } - Context.getNotificationManager().updateEvent(event, null); + if (Context.getNotificationManager() != null) { + Context.getNotificationManager().updateEvent(event, null); + } } device.setStatus(status); diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java index 7593367a3..ab6b2230a 100644 --- a/src/org/traccar/database/NotificationManager.java +++ b/src/org/traccar/database/NotificationManager.java @@ -41,8 +41,8 @@ public class NotificationManager { Set<Long> users = Context.getPermissionsManager().getDeviceUsers(event.getDeviceId()); for (Long userId : users) { - if (event.getGeofenceId() == 0 - || Context.getGeofenceManager().checkGeofence(userId, event.getGeofenceId())) { + if (event.getGeofenceId() == 0 || Context.getGeofenceManager() != null + && Context.getGeofenceManager().checkGeofence(userId, event.getGeofenceId())) { Context.getConnectionManager().updateEvent(userId, event, position); } } |