Skip to content

API: Event Management

aashah edited this page Jun 12, 2013 · 30 revisions

Related Pages: Introduction to Receivers

General Overview

The EventManager provides a way for your drivers and custom code to provide data in an event-driven design. At the core, the event manager is a simple push-pull system. We maintain the events with an Queue data structure.

Technical Overview

Every event is identified by an accompanying EventType that will act as a handle for capturing the events. The ordering of events as they get fired are also preserved through the use of Java's ConcurrentLinkedQueue.

API Overview

The two primary methods for communication with the EventManager are fireEvent and registerReceiver

Firing Events

public void fireEvent(EventType type, Object data)

To submit an event into the manager, we use fireEvent method, which takes an EventType and an Object, and adds this newly formed Event into our queue. The manager will also make a subsequent call to sendEvent, an private method discussed below.


private void sendEvent()

This private method takes the head of the queue (note again, that the order Events are fired are taken into account by the structure used to store them) and sends the event to any registered receivers at the time of sending the event.

Receiving Events

Related pages: Introduction to Receivers

To begin receiving events, you must first register your InputReceiver into the EventManager for a given event (again, identified by an EventType). The event manager uses this list to know which receivers will get an event when fired.


public void registerReceiver(EventType type, InputReceiver receiver)

Registers the given receiver, letting the manager know that receiver is available to receiver input for the given type.

Removing Receivers

public void removeReceivers(EventType type)

Removes all receivers registered under the given input type. This is ideal for a driver's destroy() method for when it can properly handle removing it's resources.

Clone this wiki locally