Clean events map
Closed this issue · 4 comments
Every day the bot adds thousands of events that accumulate in the map shown below. It would be better to find a way to cleanse it of older events.
This map in MessageListener class:
private final Map<String, Consumer<GenericMessageReactionEvent>> events = new HashMap<>();
It grows continuously if I use methods without timeout. On the other hand, if I set the timeout, the WebSocketClient disconnects every 15/20 minutes.
You can get the events map with Pages.getHandler()
then use removeEvent(Message)
to remove an event from it, or delete the messages which also trigger event removal. Nonetheless I'll add a clear()
method to it for cleanup on the next update.
About the timeout, I'm not sure it's the reason for WebSocketClient disconnects since it uses Executors as scheduler, maybe it's something else?
About the timeout, I'm not sure it's the reason for WebSocketClient disconnects since it uses Executors as scheduler, maybe it's something else?
The only operation I did was to switch from paginate
with timeout to paginate
without and I solved it.
You can get the events map with Pages.getHandler() then use removeEvent(Message) to remove an event from it, or delete the messages which also trigger event removal. Nonetheless I'll add a clear() method to it for cleanup on the next update.
ok, thanks! But there is a method that return all events registered ?
ok, thanks! But there is a method that return all events registered ?
No since direct manipulation of the map would be very bad for the library itself.
Added clear()
and getEventMap()
for MessageHandler
in release 2.2.0.
Do note, however, that the returned map is unmodifiable.