Skip to content

API: Introduction to Receivers

aashah edited this page Jun 12, 2013 · 6 revisions

At the core, receivers are adapters providing a way to abstract data received by the Event. See here for more information about event management. By creating your own InputReceiver, you allow for your own classes to extend your receiver.

The benefits of creating your own InputReceiver are that you have a higher degree of control over the data coming from the events. We can see this from the example found here, where managing the hand positions was incorporated into our MyHandReceiver.

The other benefit of adding your own InputReceiver is so that your code remains more organized. Simple implementing the InputReceiver could lead to the following code:

public class MyModule extends ProcessingModule implements InputReceiver {
    public void receiveInput(EventType type, Object data) {
        switch (type) {
            case EventType.FOO:
                ...
                break;
            case EventType.BAR:
                ...
                break;
        }
    }
}

Here, events related to multiple functionalities would have to be differentiated within one method.

For a list of receivers that have been contributed to the standard library, please take a look here.

Clone this wiki locally