示例#1
0
        private async Task <bool> CheckIfAccountIsHacked(string email)
        {
            Utils.SplitEmailAddress(email, out var username, out var domain);
            var domainGrain = system.ActorOf <IDomainGrain>(domain);

            return(await domainGrain.Ask <bool>(new CheckMail { Account = username }));
        }
示例#2
0
 public async Task <bool> AddEmail(string email)
 {
     try
     {
         MailAddress emailAddress = new MailAddress(email);
         var         domain       = client.ActorOf <IDomain>(emailAddress.Host);
         await domain.Tell(new AddEmail(email));
     }
     catch (EmailConflictException)
     {
         return(false);
     }
     catch (FormatException)
     {
         throw new FormatException(String.Format("Invalid email format: '{0}'.", email));
     }
     return(true);
 }
示例#3
0
        static async Task Run()
        {
            var item = system.ActorOf <IInventoryItem>("12345");

            await item.Tell(new Create("XBOX1"));

            await Print(item);

            await item.Tell(new CheckIn(10));

            await Print(item);

            await item.Tell(new CheckOut(5));

            await Print(item);

            await item.Tell(new Rename("XBOX360"));

            await Print(item);
        }
示例#4
0
        static async Task Run(IClientActorSystem system)
        {
            var some    = system.ActorOf <ISomeActor>("some");
            var another = system.ActorOf <IAnotherActor>("another");

            var actor = await some.Ask(new GetSelf());

            var stream = await some.Ask(new GetStream());

            var item1 = new Item {
                Name = "PS3", Paid = DateTimeOffset.UtcNow.AddHours(-2), Price = 600
            };
            var item2 = new Item {
                Name = "XBOX", Paid = DateTimeOffset.UtcNow.AddHours(-9), Price = 500
            };

            await another.Tell(new Notify { Observer = actor, Item = item1 });

            await another.Tell(new Push { Stream = stream, Item = item2 });

            var received = await some.Ask(new GetReceived());

            Verify(received[0], item1);
            Verify(received[1], item2);

            using (var observable = await system.CreateObservable())
            {
                Item observed = null;
                using (observable.Subscribe <Item>(x => observed = x))
                {
                    var item3 = new Item {
                        Name = "Nintendo", Paid = DateTimeOffset.UtcNow, Price = 300
                    };
                    await another.Tell(new Notify { Observer = observable.Ref, Item = item3 });

                    Thread.Sleep(2000);
                    Verify(observed, item3);
                }
            }
        }
示例#5
0
 public ChatClient(IClientActorSystem system, string user, string room)
 {
     this.system = system;
     this.user   = user;
     this.room   = system.ActorOf <IChatRoom>(room);
 }
示例#6
0
 public ChatClient(IClientActorSystem system, string user, string room)
 {
     this.system = system;
     this.user   = user;
     this.room   = system.ActorOf($"ChatRoom:{room}");
 }