Skip to content

Listeners

omarathon edited this page Aug 11, 2019 · 2 revisions

Overview

One may create their own CrawlerListener to listen to the events generated from the Crawler in its operation. Each event has a void handler method which is called from the Crawler, with its CrawlerListener instance.

Events

Please refer to the CrawlerListener class to see the possible events, and the Crawler classes to see when they're triggered. Additional information is given as a comment on each of the events in the CrawlerListener class.

Usage

Simply implement the CrawlerListener interface. Then, when constructing a Crawler, pass your CrawlerListener into its constructor to use it.

Example

One may simply implement all the event methods from the CrawlerListener class for their own CrawlerListener.

If one seeks to only extend the DefaultCrawlerListener, e.g for adding additional functionality ontop of the default functionality, then this may be done for a single handler as follows:

public class ExampleCrawlerListener extends DefaultCrawlerListener {
    @Override
    public void onCrawlSummoner(Summoner summoner) {
        super.onCrawlSummoner(summoner);
        // additional functionality goes here...
    }
}

Presets

There is a single preset CrawlerListener: the DefaultCrawlerListener, which simply prints to System.out relevant information regarding each event. This can be located in presets/listeners.

Clone this wiki locally