コード例 #1
0
        private void Behavior()
        {
            var on_lost = Handle <LostLetter>();

            on_lost += letter =>
            {
                if (!System.Config.LogLostLetters)
                {
                    return;
                }

                ActorLog.Info(
                    $"Message from \"{letter.Sender.Path.Path}\" containing " +
                    $"{letter.Data.GetType().Name} did not reach target " +
                    $"at \"{letter.Receiver.Path}\". " +
                    "Data: {0}", new object[] { letter.Data }
                    );
            };

            var on_any = AnyHandler();

            on_any += msg =>
            {
                ActorLog.Warning(
                    $"{nameof(LostLetters)} got a message that was not of {nameof(LostLetter)}!"
                    );
            };
        }
コード例 #2
0
        private void Behavior1()
        {
            var respond = Handler <(string Command, string Message)> .Create(this);

            respond += msg => StrEq(msg.Command, "LOG");
            respond += msg =>
            {
                ActorLog.Info(msg.Message);
            };
        }
コード例 #3
0
        internal override void InformParentOfError(Exception e)
        {
            if (Children.Count == 0)
            {
                ActorLog.Warning("Tried to inform root supervisor of an error when it has no children to error");
                return;
            }
            var child_ref = Children[0];
            var fault     = new Fault(System, Self.Path, child_ref, e);

            Self.Tell(fault, child_ref);
        }
コード例 #4
0
        private void Behavior()
        {
            var on_fault = Handle <Fault>();

            on_fault += fault =>
            {
                ActorLog.Fatal(
                    fault.Exception,
                    $"System supervisor encountered an unhandled exception. " +
                    $"Actor system will now be shut down."
                    );

                fault.Destroy();

                System.Shutdown();
            };
        }