aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/MainModule.java11
-rw-r--r--src/main/java/org/traccar/config/Keys.java8
2 files changed, 18 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/MainModule.java b/src/main/java/org/traccar/MainModule.java
index 6a2fe21c3..b1a8006ee 100644
--- a/src/main/java/org/traccar/MainModule.java
+++ b/src/main/java/org/traccar/MainModule.java
@@ -28,6 +28,7 @@ import io.netty.util.Timer;
import org.apache.velocity.app.VelocityEngine;
import org.traccar.broadcast.BroadcastService;
import org.traccar.broadcast.MulticastBroadcastService;
+import org.traccar.broadcast.RedisBroadcastService;
import org.traccar.broadcast.NullBroadcastService;
import org.traccar.config.Config;
import org.traccar.config.Keys;
@@ -340,8 +341,16 @@ 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)) {
- return new MulticastBroadcastService(config, objectMapper);
+ switch (broadcastType) {
+ case "multicast":
+ return new MulticastBroadcastService(config, objectMapper);
+ case "redis":
+ return new RedisBroadcastService(config, objectMapper);
+ default:
+ return new NullBroadcastService();
+ }
}
return new NullBroadcastService();
}
diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java
index d4780ba46..6f42e8937 100644
--- a/src/main/java/org/traccar/config/Keys.java
+++ b/src/main/java/org/traccar/config/Keys.java
@@ -1756,6 +1756,14 @@ public final class Keys {
"time,position,speed,course,accuracy,result");
/**
+ * Broadcast method. Available options are "multicast" and "redis". Default is "multicast".
+ */
+ public static final ConfigKey<String> BROADCAST_TYPE = new StringConfigKey(
+ "broadcast.type",
+ List.of(KeyType.CONFIG),
+ "multicast");
+
+ /**
* Multicast interface. It can be either an IP address or an interface name.
*/
public static final ConfigKey<String> BROADCAST_INTERFACE = new StringConfigKey(