Versions Compared

Key

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

...

Code Block
languagec#
themeEmacs
public class ReActor : ReceiveActor
{
  private ILoggingAdapter log = Context.GetLogger();

  public ReActor()
  {
      string myPath = Self.Path.ToString();

      Receive<string>(message => {
          Handle(message);                
      });

      Receive<DelayReply>(message => {
          Handle(message);
      });
  }

  public void Handle(string str)      //InMessage
  {
      Task.Run(async () =>
      {
          await Task.Delay(1000); //어떠한 값을 기다림동기적함수를 호출하여 지연시키지만 액터는 멈추지 않습니다.
          DelayReply reply = new DelayReply();
          reply.message = str;
          return reply;
      }).PipeTo(Self);
  }

  public void Handle(DelayReply data) //Out
  {
      string logtrace = string.Format("I'am {0} RE:{1}", Self.Path, data.message);
      log.Info(data.message);
      Sender.Tell(data);
  }
          
}

...