diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-12-29 22:38:33 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-12-29 22:38:33 -0800 |
commit | 449941043a8303e1cca7c63b28e84b6b53c6871c (patch) | |
tree | 82ccd6430eb6f6fe6e199fb2b7fb46aef9e1f3bb | |
parent | bdb4aea7ddb7f525d5c476077a88d905d261fdb8 (diff) | |
download | trackermap-server-449941043a8303e1cca7c63b28e84b6b53c6871c.tar.gz trackermap-server-449941043a8303e1cca7c63b28e84b6b53c6871c.tar.bz2 trackermap-server-449941043a8303e1cca7c63b28e84b6b53c6871c.zip |
Migrate more keys
-rw-r--r-- | src/main/java/org/traccar/BasePipelineFactory.java | 32 | ||||
-rw-r--r-- | src/main/java/org/traccar/BaseProtocolDecoder.java | 2 | ||||
-rw-r--r-- | src/main/java/org/traccar/Context.java | 2 | ||||
-rw-r--r-- | src/main/java/org/traccar/config/Keys.java | 15 |
4 files changed, 28 insertions, 23 deletions
diff --git a/src/main/java/org/traccar/BasePipelineFactory.java b/src/main/java/org/traccar/BasePipelineFactory.java index ab781fd7a..642c75ea9 100644 --- a/src/main/java/org/traccar/BasePipelineFactory.java +++ b/src/main/java/org/traccar/BasePipelineFactory.java @@ -55,13 +55,11 @@ public abstract class BasePipelineFactory extends ChannelInitializer<Channel> { private final TrackerServer server; private final String protocol; - private final boolean eventsEnabled; private int timeout; public BasePipelineFactory(TrackerServer server, String protocol) { this.server = server; this.protocol = protocol; - eventsEnabled = Context.getConfig().getBoolean(Keys.EVENT_ENABLE); timeout = Context.getConfig().getInteger(Keys.PROTOCOL_TIMEOUT.withPrefix(protocol)); if (timeout == 0) { timeout = Context.getConfig().getInteger(Keys.SERVER_TIMEOUT); @@ -122,10 +120,7 @@ public abstract class BasePipelineFactory extends ChannelInitializer<Channel> { GeolocationHandler.class, HemisphereHandler.class, DistanceHandler.class, - RemoteAddressHandler.class); - - addHandlers( - pipeline, + RemoteAddressHandler.class, FilterHandler.class, GeocoderHandler.class, SpeedLimitHandler.class, @@ -134,21 +129,16 @@ public abstract class BasePipelineFactory extends ChannelInitializer<Channel> { EngineHoursHandler.class, ComputedAttributesHandler.class, WebDataHandler.class, - DefaultDataHandler.class); - - if (eventsEnabled) { - addHandlers( - pipeline, - CommandResultEventHandler.class, - OverspeedEventHandler.class, - FuelDropEventHandler.class, - MotionEventHandler.class, - GeofenceEventHandler.class, - AlertEventHandler.class, - IgnitionEventHandler.class, - MaintenanceEventHandler.class, - DriverEventHandler.class); - } + DefaultDataHandler.class, + CommandResultEventHandler.class, + OverspeedEventHandler.class, + FuelDropEventHandler.class, + MotionEventHandler.class, + GeofenceEventHandler.class, + AlertEventHandler.class, + IgnitionEventHandler.class, + MaintenanceEventHandler.class, + DriverEventHandler.class); pipeline.addLast(new MainEventHandler()); } diff --git a/src/main/java/org/traccar/BaseProtocolDecoder.java b/src/main/java/org/traccar/BaseProtocolDecoder.java index 78282b4a5..71e43df5c 100644 --- a/src/main/java/org/traccar/BaseProtocolDecoder.java +++ b/src/main/java/org/traccar/BaseProtocolDecoder.java @@ -256,7 +256,7 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder { @Override protected Object handleEmptyMessage(Channel channel, SocketAddress remoteAddress, Object msg) { DeviceSession deviceSession = getDeviceSession(channel, remoteAddress); - if (config.getBoolean("database.saveEmpty") && deviceSession != null) { + if (config.getBoolean(Keys.DATABASE_SAVE_EMPTY) && deviceSession != null) { Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); getLastLocation(position, null); diff --git a/src/main/java/org/traccar/Context.java b/src/main/java/org/traccar/Context.java index a870edb4b..488dd9a15 100644 --- a/src/main/java/org/traccar/Context.java +++ b/src/main/java/org/traccar/Context.java @@ -332,7 +332,7 @@ public final class Context { driversManager = new DriversManager(dataManager); - commandsManager = new CommandsManager(dataManager, config.getBoolean("commands.queueing")); + commandsManager = new CommandsManager(dataManager, config.getBoolean(Keys.COMMANDS_QUEUEING)); } diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java index da6c46ee9..d443509e5 100644 --- a/src/main/java/org/traccar/config/Keys.java +++ b/src/main/java/org/traccar/config/Keys.java @@ -315,6 +315,13 @@ public final class Keys { 300L); /** + * Store empty messages as positions. For example, heartbeats. + */ + public static final ConfigKey<Boolean> DATABASE_SAVE_EMPTY = new ConfigKey<>( + "database.saveEmpty", + Collections.singletonList(KeyType.GLOBAL)); + + /** * Device limit for self registered users. Default value is -1, which indicates no limit. */ public static final ConfigKey<Integer> USERS_DEFAULT_DEVICE_LIMIT = new ConfigKey<>( @@ -553,6 +560,14 @@ public final class Keys { Collections.singletonList(KeyType.GLOBAL)); /** + * Enable commands queuing when devices are offline. Commands are buffered in memory only, so restarting service + * will clear the buffer. + */ + public static final ConfigKey<Boolean> COMMANDS_QUEUEING = new ConfigKey<>( + "commands.queueing", + Collections.singletonList(KeyType.GLOBAL)); + + /** * SMS API service full URL. Enables SMS commands and notifications. */ public static final ConfigKey<String> SMS_HTTP_URL = new ConfigKey<>( |