aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
authorRafael E. Ajuria <reajuria@users.noreply.github.com>2023-06-07 02:28:53 +0000
committerRafael E. Ajuria <reajuria@users.noreply.github.com>2023-06-07 02:28:53 +0000
commitcfd91d45b6731e6632ebb8a4913f807bab510707 (patch)
tree7e1ff676c5c38c0cd03854c0c1d6013c96a39acd /src/main/java/org/traccar
parent3c8acbd681409a068f3428ce2cbd8cf002d0b974 (diff)
downloadtrackermap-server-cfd91d45b6731e6632ebb8a4913f807bab510707.tar.gz
trackermap-server-cfd91d45b6731e6632ebb8a4913f807bab510707.tar.bz2
trackermap-server-cfd91d45b6731e6632ebb8a4913f807bab510707.zip
redis broadcast implementation
Diffstat (limited to 'src/main/java/org/traccar')
-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(