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
}
假设我的初始状态是“Rule1”并且它不断在状态之间切换,如果它在“Rule1”中,它会移动到“Rule2”,反之亦然,基于某些条件它必须将消息发送回呼叫者(发件人)。
感谢你的帮助!