From a39af3b4d72f3ed8a6dfe868d365d6bbf34e18d3 Mon Sep 17 00:00:00 2001 From: "Rafael E. Ajuria" Date: Fri, 9 Jun 2023 01:15:52 +0000 Subject: cleanup Breaking change: if using multicast must set broadcast.type="multicast" --- src/main/java/org/traccar/MainModule.java | 18 +++++++----------- .../org/traccar/broadcast/BaseBroadcastService.java | 2 +- src/main/java/org/traccar/config/Keys.java | 5 +++-- 3 files changed, 11 insertions(+), 14 deletions(-) (limited to 'src/main/java/org') diff --git a/src/main/java/org/traccar/MainModule.java b/src/main/java/org/traccar/MainModule.java index 29d846154..950a7278a 100644 --- a/src/main/java/org/traccar/MainModule.java +++ b/src/main/java/org/traccar/MainModule.java @@ -341,18 +341,14 @@ public class MainModule extends AbstractModule { @Provides public static BroadcastService provideBroadcastService( Config config, ObjectMapper objectMapper) throws IOException { - String broadcastType = config.getString(Keys.BROADCAST_TYPE); - if (config.hasKey(Keys.BROADCAST_ADDRESS)) { - switch (broadcastType) { - case "multicast": - return new MulticastBroadcastService(config, objectMapper); - case "redis": - return new RedisBroadcastService(config, objectMapper); - default: - break; - } + switch (config.getString(Keys.BROADCAST_TYPE)) { + case "multicast": + return new MulticastBroadcastService(config, objectMapper); + case "redis": + return new RedisBroadcastService(config, objectMapper); + default: + return new NullBroadcastService(); } - return new NullBroadcastService(); } @Singleton diff --git a/src/main/java/org/traccar/broadcast/BaseBroadcastService.java b/src/main/java/org/traccar/broadcast/BaseBroadcastService.java index 1ed639dfd..a95d333f2 100644 --- a/src/main/java/org/traccar/broadcast/BaseBroadcastService.java +++ b/src/main/java/org/traccar/broadcast/BaseBroadcastService.java @@ -115,4 +115,4 @@ public abstract class BaseBroadcastService implements BroadcastService { } } -} \ No newline at end of file +} diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java index 381e3a108..78e081ce5 100644 --- a/src/main/java/org/traccar/config/Keys.java +++ b/src/main/java/org/traccar/config/Keys.java @@ -1756,12 +1756,13 @@ public final class Keys { "time,position,speed,course,accuracy,result"); /** - * Broadcast method. Available options are "multicast" and "redis". Default is "multicast". + * Broadcast method. Available options are "multicast" and "redis". By default (if the value is not + * specified or does not matches available options) server disables broadcast. */ public static final ConfigKey BROADCAST_TYPE = new StringConfigKey( "broadcast.type", List.of(KeyType.CONFIG), - "multicast"); + ""); /** * Multicast interface. It can be either an IP address or an interface name. -- cgit v1.2.3