rero.bridges.event
Class EventBridge
java.lang.Object
rero.bridges.event.EventBridge
- All Implemented Interfaces:
- Environment, FilterEnvironment, Loadable, PredicateEnvironment
- public class EventBridge
- extends Object
- implements Loadable, Environment, PredicateEnvironment, FilterEnvironment
Man, I feel bad for the mantainer of this class. Oh wait thats me. Actually its not that bad.
However this class isn't just as straight forward as registering any kind of event and going
with it one way. Nope, there are 3 ways events can be handled.
1. normal chat event i.e. on JOIN for a channel join
this is handled by adding the code to a collapsed listener (i.e. one real listener attached to
the framework for the JOIN event). If the collapsed listener does not exist it is created and
registered with the irc framework.
2. temporary chat event i.e. on PART for a channel part
temporary chat events are handled by just creating a real listener and attaching it to the framework
as a temporary listener. No muss, no fuss.
3. "registered" listeners i.e. on WINDOW
registered listeners are listeners that aren't really IRC events. They have there own framework
for dealing with themselves. There is a super class ScriptedEventListener that provides the interface
the event bridge works with. Other frameworks have a listener class that extends ScriptedEventListener
and know to fire dispatchEvent when the listener is fired. This should be more efficient as it keeps
overhead low on some high occurence events (i.e. on WINDOW) and keeps the framework from being mucked
up with tons of events. All valuable things right.
Method Summary |
void |
announceFramework(ChatFramework f)
|
void |
bindFilteredFunction(ScriptInstance si,
String typeKeyword,
String keyword,
String filter,
Block functionBody)
|
void |
bindFunction(ScriptInstance si,
String type,
String name,
Block code)
|
void |
bindPredicate(ScriptInstance si,
String type,
Check pred,
Block code)
|
protected EventChatListener |
getListenerFor(String event_name)
|
protected EventChatListener |
getNewListenerFor(String event_name)
|
void |
registerEvent(String name,
ScriptedEventListener listener)
adds another type of "event" for the event bridge to manage. |
boolean |
scriptLoaded(ScriptInstance si)
|
boolean |
scriptUnloaded(ScriptInstance si)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
listeners
protected HashMap listeners
framework
protected ChatFramework framework
registeredEvents
protected HashMap registeredEvents
unloadEvents
protected HashMap unloadEvents
EventBridge
public EventBridge()
announceFramework
public void announceFramework(ChatFramework f)
scriptUnloaded
public boolean scriptUnloaded(ScriptInstance si)
- Specified by:
scriptUnloaded
in interface Loadable
scriptLoaded
public boolean scriptLoaded(ScriptInstance si)
- Specified by:
scriptLoaded
in interface Loadable
registerEvent
public void registerEvent(String name,
ScriptedEventListener listener)
- adds another type of "event" for the event bridge to manage. By default events are just registered with the irc
framework. ScriptedEventListener allows any sort of event to be incorporated into the client scripting
getNewListenerFor
protected EventChatListener getNewListenerFor(String event_name)
getListenerFor
protected EventChatListener getListenerFor(String event_name)
bindFilteredFunction
public void bindFilteredFunction(ScriptInstance si,
String typeKeyword,
String keyword,
String filter,
Block functionBody)
- Specified by:
bindFilteredFunction
in interface FilterEnvironment
bindPredicate
public void bindPredicate(ScriptInstance si,
String type,
Check pred,
Block code)
- Specified by:
bindPredicate
in interface PredicateEnvironment
bindFunction
public void bindFunction(ScriptInstance si,
String type,
String name,
Block code)
- Specified by:
bindFunction
in interface Environment