Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.
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

Closed
@hlxid

Description

@hlxid

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

  1. 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 = ()
}
  1. Start the plugin. Notice that every chat message is printed once, as it should.
  2. 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 workinghelp wantedExtra attention is neededioRelies on a connector / input / output / parameterurgentWhen something is more than just 'it's an open source project' important

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions