diff options
author | Anton Tananaev <anton@traccar.org> | 2022-07-13 17:31:52 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-07-13 17:31:52 -0700 |
commit | a8e38b74e5fc6789676bf35a9b92594a230e3ad8 (patch) | |
tree | eed89969aecd7c9652f8640742530c96a4fc40b3 /src/main/java/org/traccar/broadcast | |
parent | 33733f835e88a62c4a5259ab330723b88037adf1 (diff) | |
download | trackermap-server-a8e38b74e5fc6789676bf35a9b92594a230e3ad8.tar.gz trackermap-server-a8e38b74e5fc6789676bf35a9b92594a230e3ad8.tar.bz2 trackermap-server-a8e38b74e5fc6789676bf35a9b92594a230e3ad8.zip |
Avoid broadcast loops (fix #4894)
Diffstat (limited to 'src/main/java/org/traccar/broadcast')
-rw-r--r-- | src/main/java/org/traccar/broadcast/BroadcastInterface.java | 3 | ||||
-rw-r--r-- | src/main/java/org/traccar/broadcast/MulticastBroadcastService.java | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/broadcast/BroadcastInterface.java b/src/main/java/org/traccar/broadcast/BroadcastInterface.java index 69e610dc6..dddba68b6 100644 --- a/src/main/java/org/traccar/broadcast/BroadcastInterface.java +++ b/src/main/java/org/traccar/broadcast/BroadcastInterface.java @@ -31,10 +31,11 @@ public interface BroadcastInterface { default void updateEvent(boolean local, long userId, Event event) { } - default void invalidateObject(Class<? extends BaseModel> clazz, long id) { + default void invalidateObject(boolean local, Class<? extends BaseModel> clazz, long id) { } default void invalidatePermission( + boolean local, Class<? extends BaseModel> clazz1, long id1, Class<? extends BaseModel> clazz2, long id2) { } diff --git a/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java b/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java index be24989dd..3eafe07d3 100644 --- a/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java +++ b/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java @@ -98,7 +98,7 @@ public class MulticastBroadcastService implements BroadcastService { } @Override - public void invalidateObject(Class<? extends BaseModel> clazz, long id) { + public void invalidateObject(boolean local, Class<? extends BaseModel> clazz, long id) { BroadcastMessage message = new BroadcastMessage(); message.setChanges(Map.of(Permission.getKey(clazz), id)); sendMessage(message); @@ -106,6 +106,7 @@ public class MulticastBroadcastService implements BroadcastService { @Override public void invalidatePermission( + boolean local, Class<? extends BaseModel> clazz1, long id1, Class<? extends BaseModel> clazz2, long id2) { BroadcastMessage message = new BroadcastMessage(); @@ -137,10 +138,12 @@ public class MulticastBroadcastService implements BroadcastService { if (iterator.hasNext()) { var second = iterator.next(); listeners.forEach(listener -> listener.invalidatePermission( + false, Permission.getKeyClass(first.getKey()), first.getValue(), Permission.getKeyClass(second.getKey()), second.getValue())); } else { listeners.forEach(listener -> listener.invalidateObject( + false, Permission.getKeyClass(first.getKey()), first.getValue())); } } |