aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/broadcast
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-09-29 17:57:22 -0700
committerAnton Tananaev <anton@traccar.org>2022-09-29 17:57:22 -0700
commit0a853f2aa3556554acd0b43a5008c43c345fa300 (patch)
treeafbcf9d7924ba44e9bd0b33654f1e1fee0ff1104 /src/main/java/org/traccar/broadcast
parente7bd758824386e4f77f78ceca57675ef7934435a (diff)
downloadtrackermap-server-0a853f2aa3556554acd0b43a5008c43c345fa300.tar.gz
trackermap-server-0a853f2aa3556554acd0b43a5008c43c345fa300.tar.bz2
trackermap-server-0a853f2aa3556554acd0b43a5008c43c345fa300.zip
Synchronize queued commands
Diffstat (limited to 'src/main/java/org/traccar/broadcast')
-rw-r--r--src/main/java/org/traccar/broadcast/BroadcastInterface.java3
-rw-r--r--src/main/java/org/traccar/broadcast/BroadcastMessage.java10
-rw-r--r--src/main/java/org/traccar/broadcast/MulticastBroadcastService.java9
3 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/broadcast/BroadcastInterface.java b/src/main/java/org/traccar/broadcast/BroadcastInterface.java
index dddba68b6..673ebd8b8 100644
--- a/src/main/java/org/traccar/broadcast/BroadcastInterface.java
+++ b/src/main/java/org/traccar/broadcast/BroadcastInterface.java
@@ -31,6 +31,9 @@ public interface BroadcastInterface {
default void updateEvent(boolean local, long userId, Event event) {
}
+ default void updateCommand(boolean local, long deviceId) {
+ }
+
default void invalidateObject(boolean local, Class<? extends BaseModel> clazz, long id) {
}
diff --git a/src/main/java/org/traccar/broadcast/BroadcastMessage.java b/src/main/java/org/traccar/broadcast/BroadcastMessage.java
index 3e22be7e0..985848d04 100644
--- a/src/main/java/org/traccar/broadcast/BroadcastMessage.java
+++ b/src/main/java/org/traccar/broadcast/BroadcastMessage.java
@@ -63,6 +63,16 @@ public class BroadcastMessage {
this.event = event;
}
+ private Long commandDeviceId;
+
+ public Long getCommandDeviceId() {
+ return commandDeviceId;
+ }
+
+ public void setCommandDeviceId(Long commandDeviceId) {
+ this.commandDeviceId = commandDeviceId;
+ }
+
private Map<String, Long> changes;
public Map<String, Long> getChanges() {
diff --git a/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java b/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java
index be65b7826..b1b66f1e3 100644
--- a/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java
+++ b/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java
@@ -103,6 +103,13 @@ public class MulticastBroadcastService implements BroadcastService {
}
@Override
+ public void updateCommand(boolean local, long deviceId) {
+ BroadcastMessage message = new BroadcastMessage();
+ message.setCommandDeviceId(deviceId);
+ sendMessage(message);
+ }
+
+ @Override
public void invalidateObject(boolean local, Class<? extends BaseModel> clazz, long id) {
BroadcastMessage message = new BroadcastMessage();
message.setChanges(Map.of(Permission.getKey(clazz), id));
@@ -136,6 +143,8 @@ public class MulticastBroadcastService implements BroadcastService {
listeners.forEach(listener -> listener.updatePosition(false, message.getPosition()));
} else if (message.getUserId() != null && message.getEvent() != null) {
listeners.forEach(listener -> listener.updateEvent(false, message.getUserId(), message.getEvent()));
+ } else if (message.getCommandDeviceId() != null) {
+ listeners.forEach(listener -> listener.updateCommand(false, message.getCommandDeviceId()));
} else if (message.getChanges() != null) {
var iterator = message.getChanges().entrySet().iterator();
if (iterator.hasNext()) {