Пример #1
0
 TestObserver(ClientObservable observable)
 {
     this.observable = observable;
     observable.Subscribe(message =>
     {
         Notifications.Add(message);
         Received.Set();
     });
 }
Пример #2
0
        public static void Initialize()
        {
            clients = GlobalHost.ConnectionManager.GetHubContext <Relay>().Clients;

            notifications = Task.Run(ClientObservable.Create).Result;
            notifications.Subscribe(On);

            Task.Run(Subscribe)
            .Wait();

            Task.Run(Resubscribe);
        }
Пример #3
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 });
        }
Пример #4
0
        public async void Run()
        {
            var facebook = system.ActorOf <Api>("facebook");
            var twitter  = system.ActorOf <Api>("twitter");

            await facebook.Tell(new Subscribe(observable));

            await twitter.Tell(new Subscribe(observable));

            observable.Subscribe(LogToConsole);

            foreach (var i in Enumerable.Range(1, 25))
            {
                var topic = system.ActorOf <Topic>(i.ToString());

                await topic.Tell(new CreateTopic("[" + i + "]", new Dictionary <ActorRef, TimeSpan>
                {
                    { facebook, TimeSpan.FromMinutes(1) },
                    { twitter, TimeSpan.FromMinutes(1) },
                }));
            }
        }