public async void Client_to_actor()
            {
                var actor = system.FreshActorOf <TestActor>();

                using (var observer = await ClientObservable.Create())
                {
                    await actor.Tell(new Attach { Observer = observer });

                    Notification @event = null;

                    var done         = new AutoResetEvent(false);
                    var subscription = observer.Subscribe((Notification e) =>
                    {
                        @event = e;
                        done.Set();
                    });

                    await actor.Tell(new Publish { Text = "c-a" });

                    done.WaitOne(TimeSpan.FromMilliseconds(100));
                    Assert.That(@event.Text, Is.EqualTo("c-a"));

                    subscription.Dispose();
                    await actor.Tell(new Publish { Text = "kaboom" });

                    done.WaitOne(TimeSpan.FromMilliseconds(100));
                    Assert.That(@event.Text, Is.EqualTo("c-a"));
                }
            }
Exemple #2
0
        public async Task Join()
        {
            notifications = await ClientObservable.Create();

            notifications.Subscribe((ChatRoomMessage msg) =>
            {
                if (msg.User != user)
                {
                    Console.WriteLine(msg.Text);
                }
            });

            await room.Tell(new Join { User = user, Client = notifications });
        }
Exemple #3
0
        public static void Main()
        {
            Console.WriteLine("Running demo. Booting cluster might take some time ...\n");

            var properties = new Dictionary <string, string>
            {
                { "account", "UseDevelopmentStorage=true" }
            };

            var system = ActorSystem.Configure()
                         .Playground()
                         .Bootstrapper <ServiceLocator.Bootstrap>(properties)
                         .Assemblies(typeof(Api).Assembly)
                         .Done();

            system.Start();

            client = new Client(system, ClientObservable.Create().Result);
            client.Run();

            Console.WriteLine("Press Enter to terminate ...");
            Console.ReadLine();
        }
Exemple #4
0
            public static async Task <TestObserver> Create()
            {
                var observable = await ClientObservable.Create();

                return(new TestObserver(observable));
            }