cz.cuni.amis.pogamut.base.communication.command.react
Class CommandReactOnce<COMMAND extends CommandMessage>
java.lang.Object
cz.cuni.amis.pogamut.base.communication.command.react.CommandReact<COMMAND>
cz.cuni.amis.pogamut.base.communication.command.react.CommandReactOnce<COMMAND>
- Type Parameters:
COMMAND
-
public abstract class CommandReactOnce<COMMAND extends CommandMessage>
- extends CommandReact<COMMAND>
This abstract class allows you to easily hook a specific event-handling behavior. It automatically
register a listener for a specified IWorldCommand
for you and calls CommandReactOnce#react(IWorldCommand)
method automatically. The CommandReactOnce#react(IWorldCommand)
will be called only once (upon first event received).
If you need to react every time, use CommandReact
.
Use CommandReact.enable()
and CommandReact.disable()
to enable react / disable react. The reaction is enabled
as default.
WARNING:Use as anonymous class, but save it as a field of your class! Note, that we're using weak-references to
listeners and if you do not save pointer to the object, it will be gc()ed!
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CommandReactOnce
public CommandReactOnce(java.lang.Class<COMMAND> commandClass,
IAct act)
postReact
protected void postReact(COMMAND event)
- Disables the reaction.
- Overrides:
postReact
in class CommandReact<COMMAND extends CommandMessage>