Example #1
0
 static async Task Print(TypedActorRef<InventoryItem> item)
 {
     var details = await item.Call(x => x.Details());
     
     Console.WriteLine("{0}: {1} {2}", 
                         details.Name, 
                         details.Total, 
                         details.Active ? "" : "(deactivated)");
 }
Example #2
0
        static async Task Print(TypedActorRef <InventoryItem> item)
        {
            var details = await item.Call(x => x.Details());

            Console.WriteLine("{0}: {1} {2}",
                              details.Name,
                              details.Total,
                              details.Active ? "" : "(deactivated)");
        }
Example #3
0
        public CustomerActor(int id, TypedActorRef <BankActor> bank)
        {
            _id      = id;
            _balance = 0;

            // Initialise our balance
            Self.Tell(MakeSnapshot());

            Receive <BalanceSnapshot>(snapShot =>
            {
                _balance = snapShot.Balance;
                bank.Tell(MakeSnapshot());
            });

            Receive <BalanceUpdate>(update =>
            {
                _balance += update.BalanceChange;
                bank.Tell(MakeSnapshot());
            });

            Receive <BalanceQuery>(query =>
            {
                Sender.Tell(MakeSnapshot());
            });

            Receive <SpendRandom>(msg =>
            {
                var rand = new Random();
                var sign = rand.NextDouble() > 0.5 ? 1 : -1;

                Self.Tell(new BalanceUpdate
                {
                    BalanceChange = rand.NextDouble() * sign
                });
            });
        }
Example #4
0
 public HomeController(ActorSystem actorSystem, TypedActorRef <BankActor> bank)
 {
     this._actorSystem = actorSystem;
     this._bank        = bank;
 }
Example #5
0
 public CustomerController(ActorSystem actorSystem, TypedActorRef <BankActor> bank)
 {
     _actorSystem = actorSystem;
     _bank        = bank;
 }
Example #6
0
 public ChatClient(IActorSystem system, string user, string room)
 {
     this.user = system.TypedActorOf<ChatUser>(user);
     this.room = system.StreamOf<SimpleMessageStreamProvider>(room);
 }
Example #7
0
 public ChatClient(IActorSystem system, string user, string room)
 {
     this.user = system.TypedActorOf <ChatUser>(user);
     this.room = system.StreamOf <SimpleMessageStreamProvider>(room);
 }