View Javadoc

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