コード例 #1
0
        public void CanCreateActorUsingRemoteDaemonAndInteractWithChild()
        {
            var p = new TestProbe();
            sys.EventStream.Subscribe(p.Ref, typeof(string));
            var supervisor = sys.ActorOf<SomeActor>();
            var provider = (RemoteActorRefProvider)sys.Provider;
            var daemon = provider.RemoteDaemon;
            var childCreatedEvent=new ManualResetEventSlim();


            var path = (sys.Guardian.Path + "/foo").ToString();

            //ask to create an actor MyRemoteActor, this actor has a child "child"
            daemon.Tell(new DaemonMsgCreate(Props.Create(() => new MyRemoteActor(childCreatedEvent)), null, path, supervisor));

            //Wait for the child to be created (actors are instantiated async)
            childCreatedEvent.Wait();

            //try to resolve the child actor "child"
            var child = provider.ResolveActorRef(provider.RootPath / "remote/user/foo/child".Split('/'));
            //pass a message to the child
            child.Tell("hello");
            //expect the child to forward the message to the eventstream
            p.expectMsg("hello");
        }
コード例 #2
0
ファイル: RemoteDaemonSpec.cs プロジェクト: pdoh00/akka.net
        public void CanCreateActorUsingRemoteDaemonAndInteractWithChild()
        {
            var p = new TestProbe();
            sys.EventStream.Subscribe(p.Ref, typeof(string));
            var supervisor = sys.ActorOf<SomeActor>();
            var provider = (RemoteActorRefProvider)sys.Provider;
            var daemon = provider.RemoteDaemon;

            //ask to create an actor MyRemoteActor, this actor has a child "child"
            daemon.Tell(new DaemonMsgCreate(Props.Create(() => new MyRemoteActor()), null, "user/foo", supervisor));
            //try to resolve the child actor "child"
            var child = provider.ResolveActorRef(provider.RootPath / "remote/user/foo/child".Split('/'));
            //pass a message to the child
            child.Tell("hello");
            //expect the child to forward the message to the eventstream
            p.expectMsg("hello");
        }