Main   Class List   Namespace List   Wiki

EventManager Class Reference
[Messaging]

The EventManager class is a wrapper for the standard messaging system. More...

Inheritance diagram for EventManager:
Inheritance graph
[legend]

List of all members.

Public Member Functions

void dumpEvents ()
 Print all registered events to the console.
void dumpSubscribers (String event)
 Print all subscribers to an event to the console.
bool isRegisteredEvent (String event)
 Check if an event is registered or not.
bool postEvent (String event, String data)
 ~Trigger an event.
bool registerEvent (String event)
 Register an event with the event manager.
void remove (SimObject listener, String event)
 Remove a listener from an event.
void removeAll (SimObject listener)
 Remove a listener from all events.
bool subscribe (SimObject listener, String event, String callback)
 Subscribe a listener to an event.
void unregisterEvent (String event)
 Remove an event from the EventManager.

Public Attributes

string queue
 List of events currently waiting.

Detailed Description

The EventManager class is a wrapper for the standard messaging system.

It provides functionality for management of event queues, events, and subscriptions. Creating an EventManager is as simple as calling new EventManager and specifying a queue name.

Example:
// Create the EventManager.
$MyEventManager = new EventManager() { queue = "MyEventManager"; };

// Create an event.
$MyEventManager.registerEvent( "SomeCoolEvent" );

// Create a listener and subscribe.
$MyListener = new ScriptMsgListener() { class = MyListener; };
$MyEventManager.subscribe( $MyListener, "SomeCoolEvent" );

function MyListener::onSomeCoolEvent( %this, %data )
{
     echo( "onSomeCoolEvent Triggered" );
}

// Trigger the event.
$MyEventManager.postEvent( "SomeCoolEvent", "Data" );
See also:
ScriptMsgListener

Member Function Documentation

void EventManager::dumpEvents (  ) 

Print all registered events to the console.

void EventManager::dumpSubscribers ( String  event  ) 

Print all subscribers to an event to the console.

Parameters:
event The event whose subscribers are to be printed. If this parameter isn't specified, all events will be dumped.
bool EventManager::isRegisteredEvent ( String  event  ) 

Check if an event is registered or not.

Parameters:
event The event to check.
Returns:
Whether or not the event exists.
bool EventManager::postEvent ( String  event,
String  data 
)

~Trigger an event.

Parameters:
event The event to trigger.
data The data associated with the event.
Returns:
Whether or not the event was dispatched successfully.
bool EventManager::registerEvent ( String  event  ) 

Register an event with the event manager.

Parameters:
event The event to register.
Returns:
Whether or not the event was registered successfully.
void EventManager::remove ( SimObject  listener,
String  event 
)

Remove a listener from an event.

Parameters:
listener The listener to remove.
event The event to be removed from.
void EventManager::removeAll ( SimObject  listener  ) 

Remove a listener from all events.

Parameters:
listener The listener to remove.
bool EventManager::subscribe ( SimObject  listener,
String  event,
String  callback 
)

Subscribe a listener to an event.

Parameters:
listener The listener to subscribe.
event The event to subscribe to.
callback Optional method name to receive the event notification. If this is not specified, "on[event]" will be used.
Returns:
Whether or not the subscription was successful.
void EventManager::unregisterEvent ( String  event  ) 

Remove an event from the EventManager.

Parameters:
event The event to remove.

Member Data Documentation

List of events currently waiting.



Copyright © GarageGames, LLC. All Rights Reserved.