Ejemplo n.º 1
0
        public TransactionActor(IActorRef accounting)
        {
            ReceiveAsync <Transaction>(async transaction =>
            {
                _transactionFrom = transaction.From;
                _from            = await accounting.AskObservable <IActorRef, AccountId>(_transactionFrom);
                _transactionTo   = transaction.To;
                _to               = await accounting.AskObservable <IActorRef, AccountId>(_transactionTo);
                _transactionId    = transaction.Id;
                _transactionFunds = transaction.Funds;

                _from.TellObservable(new Reserve(_transactionId, _transactionFunds, _transactionTo));
            });

            Receive <Reserved>(_ =>
            {
                _to.TellObservable(new Deposit(_transactionId, _transactionFunds, _transactionFrom));
            }, msg => msg.TransactionId.Equals(_transactionId));

            Receive <Deposited>(_ =>
            {
                _from.TellObservable(new FinalizeWithdraw(_transactionId));
            }, msg => msg.TransactionId.Equals(_transactionId));


            Receive <Withdrawn>(_ =>
            {
                Context.Stop(Self);
            }, msg => msg.TransactionId.Equals(_transactionId));
        }
Ejemplo n.º 2
0
 public async Task OpenAccount(OpenAccount openAccount)
 {
     await _accouting.AskObservable(openAccount);
 }