aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-10-03 23:07:20 +1300
committerGitHub <noreply@github.com>2016-10-03 23:07:20 +1300
commit1380c1e4453f32f8963ea41f375b2d44c2a6a8fe (patch)
tree92e62c889c72eabd6b97ebe3541fe5e709f91770
parent4a550477eb3411894f8e12e0b2bded8051b34d07 (diff)
parentc3fef40aa7ecba063c9a46f8c6e150d7ca5128d3 (diff)
downloadtrackermap-server-1380c1e4453f32f8963ea41f375b2d44c2a6a8fe.tar.gz
trackermap-server-1380c1e4453f32f8963ea41f375b2d44c2a6a8fe.tar.bz2
trackermap-server-1380c1e4453f32f8963ea41f375b2d44c2a6a8fe.zip
Merge pull request #2392 from Abyss777/status_handler
Make status events switchable
-rw-r--r--debug.xml1
-rw-r--r--src/org/traccar/database/ConnectionManager.java4
2 files changed, 4 insertions, 1 deletions
diff --git a/debug.xml b/debug.xml
index a529af327..a2d6bc3ba 100644
--- a/debug.xml
+++ b/debug.xml
@@ -50,6 +50,7 @@
<entry key='event.geofenceHandler'>true</entry>
<entry key='event.alertHandler'>true</entry>
<entry key='event.ignitionHandler'>true</entry>
+ <entry key='event.statusHandler'>true</entry>
<!--<entry key='event.forward.enable'>true</entry>
<entry key='event.forward.url'>http://localhost/</entry>
diff --git a/src/org/traccar/database/ConnectionManager.java b/src/org/traccar/database/ConnectionManager.java
index 46ccab81e..2017e81a0 100644
--- a/src/org/traccar/database/ConnectionManager.java
+++ b/src/org/traccar/database/ConnectionManager.java
@@ -40,6 +40,7 @@ public class ConnectionManager {
private static final long DEFAULT_TIMEOUT = 600;
private final long deviceTimeout;
+ private final boolean enableStatusEvents;
private final Map<Long, ActiveDevice> activeDevices = new HashMap<>();
private final Map<Long, Set<UpdateListener>> listeners = new HashMap<>();
@@ -47,6 +48,7 @@ public class ConnectionManager {
public ConnectionManager() {
deviceTimeout = Context.getConfig().getLong("status.timeout", DEFAULT_TIMEOUT) * 1000;
+ enableStatusEvents = Context.getConfig().getBoolean("event.statusHandler");
}
public void addActiveDevice(long deviceId, Protocol protocol, Channel channel, SocketAddress remoteAddress) {
@@ -73,7 +75,7 @@ public class ConnectionManager {
return;
}
- if (!status.equals(device.getStatus())) {
+ if (enableStatusEvents && !status.equals(device.getStatus())) {
Event event = new Event(Event.TYPE_DEVICE_OFFLINE, deviceId);
if (status.equals(Device.STATUS_ONLINE)) {
event.setType(Event.TYPE_DEVICE_ONLINE);