Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagec#
themeEmacs
titleUntyped Actor
linenumberstrue
    public class MyActorSame : UntypedActor   //MyActor와 동일한 기능을 하는 Actor로 OnReceive 이벤트 발생 함수를 통해 조금더 명시적(덜추상적)으로 메시지를 처리합니다.
    {        
        protected override void OnReceive(object message)
        {
            if(message is string)
            {
                if (message as string == "createChild")
                {
                    Context.ActorOf<MyActor>("myChild");
                    Sender.Tell("Create Child Succed:myChild");
                }
                else
                {
                    Sender.Tell("RE:" + message);
                }
            }
            else if(message is SomeMessage)
            {
                Sender.Tell("RE:" + (message as SomeMessage).message );
            }
        }
    }

현재까지 언급된 두가지의 Actor는 다음과같으며, 목적에의해 분리가됩니다.

...

  Untyped Actor는, 이전 섹션에서 익힌 ReceiveActor 처럼 생성자에서 Type별로 메시지 처리기를 등록하는게 아닌 , OnReceive에서 다소 직관적으로

 수신처리가 가능합니다.  다소 커스텀한 액터 작성시 또는 이방식이 더 익숙할시 이방식으로 액터를 생성하면됩니다.

...


ACTOR의 확장기능을 설명하기위해 이제부터는 UntypedActor를 사용하여 진행하겠습니다.

...