Page History
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
//foo 라고하면 행복해졌다가, bar라고하면 화나는 ACTOR , 동일한 상태에서는 상태변경없이 메시지전송
public class HotSwapActor : UntypedActor
{
//기본탑재 로그,이제부터는 시간,스레드,액터정보등이 표시된 console.writeline대신 AKKA LOG를 사용하겠습니다. using Akka.Event
private ILoggingAdapter log = Context.GetLogger();
protected override void OnReceive(object message)
{
log.Info("NORMAL:"+message.ToString());
switch (message as string)
{
case "foo":
log.Info("행복해짐");
Become(Happy);
break;
case "bar":
log.Info("화남");
Become(Angry);
break;
}
}
private void Angry(object message)
{
log.Info("Angry:" + message.ToString());
switch (message as string)
{
case "foo":
log.Info("행복해짐");
Become(Happy);
break;
case "bar":
log.Info("이미 화가났다.");
Sender.Tell("이미 화가났다.");
break;
}
}
private void Happy(object message)
{
log.Info("Happy:" + message.ToString());
switch (message as string)
{
case "foo":
log.Info("이미 행복하다.");
Sender.Tell("이미 행복하다.");
break;
case "bar":
log.Info("화남");
Become(Angry);
break;
}
}
}
|
...