mirror of
https://github.com/traccar/traccar.git
synced 2025-01-08 11:47:49 +08:00
Make status events switchable
This commit is contained in:
parent
4a550477eb
commit
bae6692356
@ -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>
|
||||
|
@ -40,6 +40,7 @@ public class ConnectionManager {
|
||||
private static final long DEFAULT_TIMEOUT = 600;
|
||||
|
||||
private final long deviceTimeout;
|
||||
private final boolean statusHandler;
|
||||
|
||||
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;
|
||||
statusHandler = 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 (statusHandler && !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);
|
||||
|
Loading…
Reference in New Issue
Block a user