コード例 #1
0
 public LocalActorRef([NotNull] ActorSystem system, [NotNull] ActorInstantiator actorInstantiator, [NotNull] ActorPath path, [NotNull] Mailbox mailbox, [NotNull] InternalActorRef supervisor)
 {
     if (system == null)
     {
         throw new ArgumentNullException("system");
     }
     if (actorInstantiator == null)
     {
         throw new ArgumentNullException("actorInstantiator");
     }
     if (path == null)
     {
         throw new ArgumentNullException("path");
     }
     if (mailbox == null)
     {
         throw new ArgumentNullException("mailbox");
     }
     if (supervisor == null)
     {
         throw new ArgumentNullException("supervisor");
     }
     _system            = system;
     _actorInstantiator = actorInstantiator;
     _path       = path;
     _mailbox    = mailbox;
     _supervisor = supervisor;
     SendSystemMessage(new CreateActor(), this);
     supervisor.SendSystemMessage(new SuperviseActor(this), this);
     _deadLetterSender = new SenderActorRef(system.DeadLetters, this);
 }
コード例 #2
0
 public void HandleMessage(Envelope envelope)
 {
     try
     {
         _currentMessage = envelope;
         var message            = envelope.Message;
         var autoHandledMessage = message as AutoHandledMessage;
         if (autoHandledMessage != null)
         {
             AutoHandleMessage(envelope);
         }
         else
         {
             var sender = new SenderActorRef(envelope.Sender, this);
             _actor.Sender = sender;
             if (_messageHandlerStack.IsEmpty)
             {
                 _actor.HandleMessage(message, sender);
             }
             else
             {
                 _messageHandlerStack.Peek()(message, sender);
             }
         }
         _currentMessage = null;
     }
     catch (Exception ex)
     {
         if (!EscalateError(ex))
         {
             throw;
         }
     }
     finally
     {
         _actor.Sender = _deadLetterSender;                 //TODO: change to use one that directs to deadletter
     }
 }