View Javadoc

1   package cz.cuni.amis.pogamut.base.communication.command;
2   
3   import cz.cuni.amis.pogamut.base.communication.connection.IWorldWriterProvider;
4   import cz.cuni.amis.pogamut.base.communication.messages.CommandMessage;
5   import cz.cuni.amis.pogamut.base.component.IComponent;
6   import cz.cuni.amis.pogamut.base.component.bus.exception.ComponentNotRunningException;
7   import cz.cuni.amis.pogamut.base.component.bus.exception.ComponentPausedException;
8   
9   /**
10   * IAct provides a way to send command messages to the world allowing you to attach
11   * listeners to outgoing commands.
12   * 
13   * @author Jimmy
14   */
15  public interface IAct extends IComponent {
16  	
17  	/**
18  	 * Execute an action in the world.
19  	 * <p><p>
20  	 * May block.
21  	 * <p><p>
22  	 * Should serialize the command object and send it through the writer that is usually provided by {@link IWorldWriterProvider}.
23  	 * 
24  	 * @return parsed message
25  	 */
26  	public void act(CommandMessage command) throws ComponentNotRunningException, ComponentPausedException;
27  	
28  	/**
29  	 * Attach listener to outgoing commands from body.
30  	 * <p><p>
31  	 * After the command is sent to the world, listener will be notified.
32  	 * 
33  	 * @param commandClass which command you want to listen to
34  	 * @param listener
35  	 */
36  	public void addCommandListener(Class commandClass, ICommandListener listener);
37  	
38  	/**
39  	 * Whether the listener is listening for commands of commandClass.
40  	 * 
41  	 * @param commandClass
42  	 * @param listener
43  	 * @return
44  	 */
45  	public boolean isCommandListening(Class commandClass, ICommandListener listener);
46  	
47  	/**
48  	 * Remove the listener to outgoing commands.
49  	 * 
50  	 * @param commandClass which command you want to listen to
51  	 * @param listener
52  	 */
53  	public void removeCommandListener(Class commandClass, ICommandListener listener);
54  
55  }