Skip to content

Commit

Permalink
Merge branch 'main' of github.com:larsid/soft-iot-dlt-client-tangle-h…
Browse files Browse the repository at this point in the history
…ornet into main
  • Loading branch information
UellingtonDamasceno committed Feb 10, 2025
2 parents aeb70c9 + 5169457 commit b7ac0ab
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/main/java/dlt/client/tangle/hornet/model/LedgerReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,30 @@ public void run() {
}

private void notifyAll(String topic, Object object, Object object2) {
if (topic != null && !topic.isEmpty()) {
Set<ILedgerSubscriber> subscribers = this.topics.get(topic);
if (subscribers != null && !subscribers.isEmpty()) {
subscribers.forEach(sub -> sub.update(object, object2));
if (topic == null || topic.isEmpty()) {
return;
}
}
Set<ILedgerSubscriber> subscribers = this.getSubscribers(topic);
if (subscribers == null || subscribers.isEmpty()) {
return;
}
subscribers.forEach(sub -> sub.update(object, object2));
}

private Set<ILedgerSubscriber> getSubscribers(String topic) {
Set<ILedgerSubscriber> subscribers = new HashSet<>();

if (topics.containsKey(topic)) {
subscribers.addAll(topics.get(topic));
}

for (Map.Entry<String, Set<ILedgerSubscriber>> entry : topics.entrySet()) {
String registeredTopic = entry.getKey();
if (registeredTopic.matches(topic.replace("*", ".*"))) {
subscribers.addAll(entry.getValue());
}
}
return subscribers;
}

public String getUrlApi() {
Expand Down

0 comments on commit b7ac0ab

Please sign in to comment.