Esempio n. 1
0
        protected override object InvokeSync <TMessage>(
            IWampRawRpcOperationRouterCallback caller,
            IWampFormatter <TMessage> formatter,
            InvocationDetails details,
            TMessage[] arguments,
            IDictionary <string, TMessage> argumentsKeywords,
            out IDictionary <string, object> outputs)
        {
            try
            {
                object[] parameters =
                    UnpackParameters(formatter, arguments, argumentsKeywords)
                    .ToArray();

                var topic = (string)parameters[0];

                var customerId = _sessionCache.GetClientId(details.AuthenticationId);

                if (topic == Topic.Balance)
                {
                    Task.Run(async() => { await _balanceUpdatePublisher.PublishAsync(customerId); });
                }

                outputs = null;

                return("");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToJson());
                throw;
            }
        }
Esempio n. 2
0
        public async Task InitializeAsync(string topic, string token)
        {
            var customerId = _sessionCache.GetClientId(token);

            if (topic == Topic.Balance)
            {
                await _balanceUpdatePublisher.PublishAsync(customerId);
            }
            if (topic == Topic.WalletStatus)
            {
                await _walletStatusUpdatePublisher.PublishAsync(customerId);
            }
        }
        protected override async Task <(bool isSuccessful, string errorMessage)> ProcessMessageAsync(CustomerBalanceUpdatedEvent message)
        {
            await _balanceUpdatePublisher.PublishAsync(message.CustomerId, message.Reason.ToString(), message.Balance, message.Timestamp);

            return(true, null);
        }