Skip to content

Commit 3741760

Browse files
committed
schedule watch listener refreshes
1 parent b174f95 commit 3741760

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/main/java/vc/live/watch/WatchManager.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import java.util.function.Function;
4646
import java.util.function.Supplier;
4747

48+
import static java.util.concurrent.TimeUnit.HOURS;
4849
import static vc.util.DiscordMarkdownEscape.escape;
4950

5051
@Component
@@ -215,6 +216,23 @@ private void processChatsKeywordQueue() {
215216
}
216217
}
217218

219+
@Scheduled(initialDelay = 1, fixedRate = 1, timeUnit = HOURS)
220+
private void refreshTopicListeners() {
221+
if (!watchesEnabled) return;
222+
try {
223+
LOGGER.info("Refreshing watch topic listeners");
224+
connectionsTopic.removeListener(connectionsTopicId);
225+
connectionsTopicId = connectionsTopic.addListener(String.class, (channel, msg) -> connectionsTopicListener(msg));
226+
chatsTopic.removeListener(chatsTopicId);
227+
chatsTopicId = chatsTopic.addListener(String.class, (channel, msg) -> chatsTopicListener(msg));
228+
deathsTopic.removeListener(deathsTopicId);
229+
deathsTopicId = deathsTopic.addListener(String.class, (channel, msg) -> deathsTopicListener(msg));
230+
LOGGER.info("Watch topic listeners refreshed");
231+
} catch (Exception e) {
232+
LOGGER.error("Failed to refresh watch topic listeners", e);
233+
}
234+
}
235+
218236
private <T> void processQueue(
219237
String id,
220238
ConcurrentLinkedDeque<T> queue,

0 commit comments

Comments
 (0)