当前位置: 首页>>代码示例>>C#>>正文


C# IInternalActorRef.Tell方法代码示例

本文整理汇总了C#中IInternalActorRef.Tell方法的典型用法代码示例。如果您正苦于以下问题:C# IInternalActorRef.Tell方法的具体用法?C# IInternalActorRef.Tell怎么用?C# IInternalActorRef.Tell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IInternalActorRef的用法示例。


在下文中一共展示了IInternalActorRef.Tell方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SystemGuardianTests

 public SystemGuardianTests()
 {
     _userGuardian = Sys.ActorOf(Props.Create<GuardianActor>()).AsInstanceOf<IInternalActorRef>();
     _systemGuardian = Sys.ActorOf(Props.Create(() => new SystemGuardianActor(_userGuardian))).AsInstanceOf<IInternalActorRef>();
     _systemGuardian.Tell(new Watch(_userGuardian, _systemGuardian));            
 }
开发者ID:rogeralsing,项目名称:akka.net,代码行数:6,代码来源:SystemGuardianTests.cs

示例2: Dispatch

        public void Dispatch(IInternalActorRef recipient, Address recipientAddress, SerializedMessage message,
            IActorRef senderOption = null)
        {
            var payload = MessageSerializer.Deserialize(system, message);
            Type payloadClass = payload == null ? null : payload.GetType();
            var sender = senderOption ?? system.DeadLetters;
            var originalReceiver = recipient.Path;

            var msgLog = string.Format("RemoteMessage: {0} to {1}<+{2} from {3}", payload, recipient, originalReceiver,
                sender);
            // message is intended for the RemoteDaemon, usually a command to create a remote actor
            if (recipient == remoteDaemon)
            {
                if (settings.UntrustedMode) log.Debug("dropping daemon message in untrusted mode");
                else
                {
                    if (settings.LogReceive) log.Debug("received daemon message [{0}]", msgLog);
                    remoteDaemon.Tell(payload);
                }
            }

            //message is intended for a local recipient
            else if ((recipient is ILocalRef || recipient is RepointableActorRef) && recipient.IsLocal)
            {
                if (settings.LogReceive) log.Debug("received local message [{0}]", msgLog);
                payload.Match()
                    .With<ActorSelectionMessage>(sel =>
                    {
                        var actorPath = "/" + string.Join("/", sel.Elements.Select(x => x.ToString()));
                        if (settings.UntrustedMode
                            && (!settings.TrustedSelectionPaths.Contains(actorPath)
                            || sel.Message is IPossiblyHarmful
                            || recipient != provider.Guardian))
                        {
                            log.Debug(
                                "operating in UntrustedMode, dropping inbound actor selection to [{0}], allow it" +
                                "by adding the path to 'akka.remote.trusted-selection-paths' in configuration",
                                actorPath);
                        }
                        else
                        {
                            //run the receive logic for ActorSelectionMessage here to make sure it is not stuck on busy user actor
                            ActorSelection.DeliverSelection(recipient, sender, sel);
                        }
                    })
                    .With<IPossiblyHarmful>(msg =>
                    {
                        if (settings.UntrustedMode)
                        {
                            log.Debug("operating in UntrustedMode, dropping inbound IPossiblyHarmful message of type {0}", msg.GetType());
                        }
                    })
                    .With<ISystemMessage>(msg => { recipient.Tell(msg); })
                    .Default(msg =>
                    {
                        recipient.Tell(msg, sender);
                    });
            }

            // message is intended for a remote-deployed recipient
            else if ((recipient is IRemoteRef || recipient is RepointableActorRef) && !recipient.IsLocal && !settings.UntrustedMode)
            {
                if (settings.LogReceive) log.Debug("received remote-destined message {0}", msgLog);
                if (provider.Transport.Addresses.Contains(recipientAddress))
                {
                    //if it was originally addressed to us but is in fact remote from our point of view (i.e. remote-deployed)
                    recipient.Tell(payload, sender);
                }
                else
                {
                    log.Error(
                        "Dropping message [{0}] for non-local recipient [{1}] arriving at [{2}] inbound addresses [{3}]",
                        payloadClass, recipient, recipientAddress, string.Join(",", provider.Transport.Addresses));
                }
            }
            else
            {
                log.Error(
                        "Dropping message [{0}] for non-local recipient [{1}] arriving at [{2}] inbound addresses [{3}]",
                        payloadClass, recipient, recipientAddress, string.Join(",", provider.Transport.Addresses));
            }
        }
开发者ID:MaciekLesiczka,项目名称:akka.net,代码行数:82,代码来源:Endpoint.cs

示例3: DeliverSelection

        /// <summary>
        ///     INTERNAL API
        ///     Convenience method used by remoting when receiving <see cref="ActorSelectionMessage" /> from a remote
        ///     actor.
        /// </summary>
        internal static void DeliverSelection(IInternalActorRef anchor, IActorRef sender, ActorSelectionMessage sel)
        {
            if (sel.Elements.IsNullOrEmpty())
            {
                anchor.Tell(sel.Message, sender);
            }
            else
            {
                var iter = sel.Elements.Iterator();

                Action<IInternalActorRef> rec = null;
                rec = @ref => @ref.Match()
                    .With<ActorRefWithCell>(refWithCell =>
                    {
                        var emptyRef = new EmptyLocalActorRef(refWithCell.Provider, anchor.Path/sel.Elements.Select(el => el.ToString()), refWithCell.Underlying.System.EventStream);

                        iter.Next()
                            .Match()
                            .With<SelectParent>(_ =>
                            {
                                var parent = @ref.Parent;
                                if (iter.IsEmpty())
                                    parent.Tell(sel.Message, sender);
                                else
                                    rec(parent);
                            })
                            .With<SelectChildName>(name =>
                            {
                                var child = refWithCell.GetSingleChild(name.Name);
                                if (child is Nobody)
                                {
                                    if (!sel.WildCardFanOut) 
                                        emptyRef.Tell(sel, sender);
                                }
                                else if (iter.IsEmpty())
                                {
                                    child.Tell(sel.Message, sender);
                                }
                                else
                                {
                                    rec(child);
                                }

                            })
                            .With<SelectChildPattern>(p =>
                            {
                                var children = refWithCell.Children;
                                var matchingChildren = children
                                    .Where(c => c.Path.Name.Like(p.PatternStr))
                                    .ToList();

                                if (iter.IsEmpty())
                                {
                                    if(matchingChildren.Count ==0 && !sel.WildCardFanOut)
                                        emptyRef.Tell(sel, sender);
                                    else
                                        matchingChildren.ForEach(child => child.Tell(sel.Message, sender));
                                }
                                else
                                {
                                    if (matchingChildren.Count == 0 && !sel.WildCardFanOut)
                                        emptyRef.Tell(sel, sender);
                                    else
                                    {
                                        var m = new ActorSelectionMessage(sel.Message, iter.ToVector().ToArray(), 
                                            sel.WildCardFanOut || matchingChildren.Count > 1);
                                        matchingChildren.ForEach(child => DeliverSelection(child as IInternalActorRef, sender, m));
                                    }
                                }
                            });
                    })
                    .Default(_ => @ref.Tell(new ActorSelectionMessage(sel.Message, iter.ToVector().ToArray()), sender));

                rec(anchor);
            }
        }
开发者ID:MaciekLesiczka,项目名称:akka.net,代码行数:81,代码来源:ActorSelection.cs


注:本文中的IInternalActorRef.Tell方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。