View Javadoc

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