class RulesFSMActor extends Actor with FSM[State, Data]{
When(Rule1)
{
case Event(CASE_MSG1, Data) =>
if (<someconditon>)
goto(Rule2)
}
When(Rule2)
{
case Event(CASE_MSG2, Data) =>
if (<someconditon>){
sender ! MessgeBackToCaller" // Is it allowed to use "sender" ?
goto(Rule1)
}
}
//unhandled ,...etc
}
Assume my initial state is "Rule1" and it keeps toggling between states, If its in "Rule1" , it moves to "Rule2" and vice versa , based on some condition it has to send a message back to Caller(Sender).
Appreciate your help!