View Javadoc

1   package cz.cuni.amis.pogamut.ut2004.communication.translator.bot.state;
2   
3   import cz.cuni.amis.fsm.FSMState;
4   import cz.cuni.amis.fsm.FSMTransition;
5   import cz.cuni.amis.fsm.IFSMState;
6   import cz.cuni.amis.pogamut.base.communication.messages.InfoMessage;
7   import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.HandShakeStart;
8   import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Password;
9   import cz.cuni.amis.pogamut.ut2004.communication.translator.TranslatorContext;
10  import cz.cuni.amis.pogamut.ut2004.communication.translator.TranslatorMessages;
11  import cz.cuni.amis.pogamut.ut2004.communication.translator.UnexpectedMessageException;
12  import cz.cuni.amis.pogamut.ut2004.communication.translator.observer.support.AbstractObserverFSMState;
13  
14  /**
15   * When the HELLO_CONTROL_SERVER message comes we switch into this state that sends the ReadyCommandRequest event to the world view
16   * and waits for next symbol, it may be:
17   * <ul>
18   * <li>Password message - switches to the PasswordState</li>
19   * <li>GameInfo message - switches to the HandshakeControllerState</li>
20   * </ul>
21   * 
22   * @author Jimmy
23   */
24  @FSMState(map = { @FSMTransition(
25  						state = PasswordState.class, 
26  						symbol = { Password.class }, 
27  						transition = {}),
28  				  @FSMTransition(
29  						state = HandshakeControllerState.class, 
30  						symbol = { HandShakeStart.class }, 
31  						transition = {})	
32  				}
33  )
34  public class ReadyState extends AbstractObserverFSMState<InfoMessage, TranslatorContext> {
35  
36  	@Override
37  	public void init(TranslatorContext context) {
38  	}
39  
40  	@Override
41  	public void restart(TranslatorContext context) {
42  	}
43  
44  	@Override
45  	public void stateEntering(TranslatorContext context,
46  			IFSMState<InfoMessage, TranslatorContext> fromState,
47  			InfoMessage symbol) {
48  	}
49  
50  	@Override
51  	public void stateLeaving(TranslatorContext context,
52  			IFSMState<InfoMessage, TranslatorContext> toState, InfoMessage symbol) {
53  	}
54  
55  	@Override
56  	protected void innerStateSymbol(TranslatorContext context, InfoMessage symbol) {
57  		throw new UnexpectedMessageException(TranslatorMessages.unexpectedMessage(this, symbol), context.getLogger(), this);
58  	}
59  
60  }