This repository was archived by the owner on Aug 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
This repository was archived by the owner on Aug 18, 2020. It is now read-only.
Event handlers have to be unregistered when a plugin or input stops #89
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is neededioRelies on a connector / input / output / parameterRelies on a connector / input / output / parameterurgentWhen something is more than just 'it's an open source project' importantWhen something is more than just 'it's an open source project' important
Description
Description
All event handlers that are registered by plugins using some inputs aren't unregistered at all.
Even after a plugin has stopped the event handler is still called for all received events.
The event handlers by all event inputs that they register in their connectors also have to be unregistered at some point, probably in their shutdown
method.
How to reproduce
- Have a simple plugin like this:
import org.codeoverflow.chatoverflow.api.plugin.{PluginImpl, PluginManager}
class SimpleTwitchChatPlugin(manager: PluginManager) extends PluginImpl(manager) {
private val in = require.input.twitchChat("twitchIn", "The twitch input, of which all messages will be displayed", false)
private val channel = "skate702"
override def setup(): Unit = {
in.get().setChannel(channel)
in.get().registerChatMessageReceiveEventHandler(ev => println(ev.getMessage))
}
override def loop(): Unit = ()
override def shutdown(): Unit = ()
}
- Start the plugin. Notice that every chat message is printed once, as it should.
- Restart the plugin, but not the framework. Notice that every chat message is printed four times.
It's printed four times, because the input has registered its internal handler twice and the plugin has the handler registered in the input twice. Each internal handler is calling all handlers by the plugin, which results in four calls.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is neededioRelies on a connector / input / output / parameterRelies on a connector / input / output / parameterurgentWhen something is more than just 'it's an open source project' importantWhen something is more than just 'it's an open source project' important